{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "83190748-4ad1-4ca2-aba2-8d3d02150be0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import os\n",
    "import numpy as np\n",
    "import seaborn as sns\n",
    "import matplotlib.pyplot as plt\n",
    "import math\n",
    "from matplotlib import cm # 导入色谱渐变处理"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "3fb6415c",
   "metadata": {},
   "source": [
    "必要的配置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ec9b0b7f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 如果文件夹不存在，在当前路径下创建文件夹\n",
    "if not os.path.isdir(\"Figures\"):\n",
    "    os.makedirs(\"Figures\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "957fd1e4-18f8-4d6e-bed3-1ec803bf8d08",
   "metadata": {},
   "source": [
    "### 定义可视化函数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "89adf3a5-e87c-4175-bd58-f5f340c727f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义绘制一元数组可视化函数\n",
    "def visualize_1D(array, title):\n",
    "    fig, ax = plt.subplots()\n",
    "\n",
    "    colors = cm.RdYlBu_r(np.linspace(0,1,len(array)))\n",
    "\n",
    "    for idx in range(len(array)):\n",
    "\n",
    "        circle_idx = plt.Circle((idx, 0), 0.5, facecolor=colors[idx], edgecolor = 'w')\n",
    "        ax.add_patch(circle_idx)\n",
    "        ax.text(idx, 0, s = str(array[idx]),\n",
    "                horizontalalignment = 'center',\n",
    "                verticalalignment = 'center')\n",
    "\n",
    "    ax.set_xlim(-0.6, 0.6 + len(array))\n",
    "    ax.set_ylim(-0.6, 0.6)\n",
    "    ax.set_aspect('equal', adjustable='box')\n",
    "    ax.axis('off')\n",
    "    fig.savefig('Figures/' + title + '.svg', format='svg')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "7928b1df",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 定义绘制二元数组可视化函数\n",
    "def visualize_2D(array, title, vmax=None, vmin=None):\n",
    "    # 如果 vmax 或 vmin 未提供，则从数组中选择最值\n",
    "    if vmax is None:\n",
    "        vmax = np.max(array)\n",
    "    if vmin is None:\n",
    "        vmin = np.min(array)\n",
    "\n",
    "    fig_width  = math.ceil(array.shape[1] * 0.5)\n",
    "    fig_length = math.ceil(array.shape[0] * 0.5)\n",
    "    \n",
    "    fig, ax = plt.subplots(figsize=(fig_width, fig_length))\n",
    "    \n",
    "    sns.heatmap(array, \n",
    "                vmax=vmax,\n",
    "                vmin=vmin,\n",
    "                annot=True,        # 增加注释\n",
    "                fmt=\".0f\",         # 注释数值的格式\n",
    "                square=True,       # 热图方格为正方形\n",
    "                cmap='RdYlBu_r',   # 指定色谱\n",
    "                linewidths=.5,     # 方格线宽\n",
    "                cbar=False,        # 不显示色谱条\n",
    "                yticklabels=False, # 不显示纵轴标签\n",
    "                xticklabels=False, # 不显示横轴标签\n",
    "                ax=ax)             # 指定绘制热图的轴\n",
    "    \n",
    "    fig.savefig('Figures/' + title + '.svg', format='svg')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0c53e650",
   "metadata": {},
   "source": [
    "### 鸢尾花数据集实验\n",
    "\n",
    "以下是鸢尾花数据集中几个例子（每行为一条数据）：\n",
    "\n",
    "| Sepal Length | Sepal Width | Petal Length | Petal Width | Class           |\n",
    "| ------------ | ----------- | ------------ | ----------- | --------------- |\n",
    "| 5.1          | 3.5         | 1.4          | 0.2         | Iris-setosa     |\n",
    "| 7.0          | 3.2         | 4.7          | 1.4         | Iris-versicolor |\n",
    "| 6.3          | 3.3         | 6.0          | 2.5         | Iris-virginica  |\n",
    "\n",
    "在机器学习任务中，我们通常将特征数据存储为一个 **二维矩阵（tensor）**，大小为 `150 x 4`，标签存储为一个向量，大小为 `150`。\n",
    "\n",
    "假设：\n",
    "\n",
    "- `features` 是一个二维数组，形状为 `(n_samples, n_features)`。\n",
    "- `labels` 是一个一维数组，形状为 `(n_samples,)`。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "ef540363",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据加载\n",
    "from sklearn.datasets import load_iris"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "b42d8835",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 加载数据\n",
    "iris = load_iris()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "e614c99f",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 获取特征和标签（已经是 NumPy 格式）\n",
    "features = iris.data  # shape: (150, 4)\n",
    "labels = iris.target  # shape: (150,)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "eebdfd99",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Features type: <class 'numpy.ndarray'>\n",
      "Labels type: <class 'numpy.ndarray'>\n",
      "Features shape: (150, 4)\n",
      "Labels shape: (150,)\n"
     ]
    }
   ],
   "source": [
    "# 查看类型和形状\n",
    "print(\"Features type:\", type(features))  # <class 'numpy.ndarray'>\n",
    "print(\"Labels type:\", type(labels))      # <class 'numpy.ndarray'>\n",
    "print(\"Features shape:\", features.shape)  # (150, 4)\n",
    "print(\"Labels shape:\", labels.shape)      # (150,)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "285817e9",
   "metadata": {},
   "outputs": [],
   "source": [
    "visualize_2D(features, '特征')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "1c5261fc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgYAAAAiCAYAAAAknRGpAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjguMCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy81sbWrAAAACXBIWXMAAA9hAAAPYQGoP6dpAAASlUlEQVR4nO2de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hq6khOTSXjUCb5NQ5Nl332IrbKapKSk8mqrCG/1qF2sFjJr3Vo2QU1dZrnSNNp8mvrSEpNJdNeQn6dTEpqKhmHD1PgkDWdxdVJfnU1Sdu3c0Sup8Ahsz0lhcy8PApkWcsudIT6WM+3UFhXx/bUVI5UVlBYH9Qdyab4eL2q27iRwv5uCqqrSEpKwtJ8kqJ6B9tTUsguzKf4eCjbfjzUp9B9kSK5lu2pKVgc1dhPyKSmpJKZc4yShlB2xXgfRdWVbNu2jfzWZkoaZO5eeifXwrTfSti8eTM/+clPeOCBB3j66ad4+eWXCQsL4+WXX2bLli2EhYXx3e9+F4fDQU9PD1FRUVPXPXV53fVkVwZ1T93A7GtZww1Z6xSzr2WtV/L8PbNvRJ+a6mqSk5M5d+4cAHa7HZ/Pd9W5qamJ/fv3M3/+/Buim2nZV/eU4PONfV7X2My+0ZCu2F7CaFBXbLczGtRNnBubmtm3/4s9f6ub3OHyc1NTM/v3H/hCj6qbSvbE++Qq2SUl+Mam0OcKOlt+Pjt37uS1117DarWSlpZGWFgY69evJz09nQMHDvDWW2+Rnp5OWloab7zxBllZWZ+bp+q5WbNnWp8vY3ZYWBjuLg8ACxYsIDJS/QNnKuiUiZ/KmSK7d+8mMTGRjo4OYmNjGRsbo7u7e9K8atUqHnroIe0/q7le3UzLnml9btbs6+3T1taG3+//4otWIBAI/kFJS0vjmWeembL+mjYGAoFAIBAIvpyI70oQCAQCgUCgITYGAoFAIBAINMTGQCAQCAQCgYbYGAgEAoFAINAQGwOBQCAQCAQaYmMgEAgEAoFAQ2wMBAKBQCAQaIiNgUAgEAgEAg2xMRAIBAKBQKAhNgYCgUAgEAg0xMZAIBAIBAKBhtgYCAQCgUAg0Pg/h8lptlk7xwwAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_1D(labels, '标签')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c481259e",
   "metadata": {},
   "source": [
    "每列特征的均值"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "295b3628",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Mean of each feature: [5.84333333 3.05733333 3.758      1.19933333]\n"
     ]
    }
   ],
   "source": [
    "mean_features = np.mean(features, axis=0)  # 每列特征的均值\n",
    "print(\"Mean of each feature:\", mean_features)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ddba707d",
   "metadata": {},
   "source": [
    "我有一个非常困惑的想法，就是，假设我想让label和feature合并在一起，我该怎么做呢？"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "6aa26823",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 合并 features 和 labels\n",
    "combined = np.column_stack((features, labels))  # 合并为 (150, 5)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "715a8975",
   "metadata": {},
   "source": [
    "`np.column_stack()` 是一个非常方便的函数，用于将一维或二维数组按 **列方向** 合并起来，适用于需要将不同数组横向拼接成一个新的二维数组的场景。\n",
    "\n",
    "---\n",
    "\n",
    "### **为什么用 `column_stack`？**\n",
    "\n",
    "1. **专为列合并设计：**\n",
    "   - `column_stack` 会自动将输入的每个数组视为列，即使它是一个一维数组。\n",
    "   - 例如，`labels` 是一维数组，`column_stack` 会将它转换成一列，而不需要你手动 reshape。\n",
    "\n",
    "2. **适合特征和标签的场景：**\n",
    "   - 特征数组通常是二维的，比如 `(150, 4)`。\n",
    "   - 标签数组通常是一维的，比如 `(150,)`。\n",
    "   - 用 `column_stack` 可以直接把一维的标签转成列，并与特征合并为 `(150, 5)`，而不需要额外的操作。\n",
    "\n",
    "3. **简化代码：**\n",
    "   - 如果不用 `column_stack`，你可能需要手动调整维度，比如用 `labels.reshape(-1, 1)` 或 `labels[:, np.newaxis]` 来把一维标签转换成列状。\n",
    "   - 用 `column_stack` 可以省略这些步骤。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "43da4797",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(5, 5)\n"
     ]
    }
   ],
   "source": [
    "# 如果不用 `column_stack`，需要手动 reshape\n",
    "\n",
    "features = np.random.rand(5, 4)  # (5, 4)\n",
    "labels = np.array([0, 1, 0, 1, 0])  # (5,)\n",
    "\n",
    "# 手动 reshape\n",
    "labels = labels.reshape(-1, 1)  # (5, 1)\n",
    "\n",
    "# 然后再用 concatenate\n",
    "combined = np.concatenate((features, labels), axis=1)\n",
    "print(combined.shape)  # (5, 5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "765f6710",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Combined Shape: (150, 5)\n",
      "First 5 rows of Combined Array:\n",
      " [[5.1 3.5 1.4 0.2 0. ]\n",
      " [4.9 3.  1.4 0.2 0. ]\n",
      " [4.7 3.2 1.3 0.2 0. ]\n",
      " [4.6 3.1 1.5 0.2 0. ]\n",
      " [5.  3.6 1.4 0.2 0. ]]\n"
     ]
    }
   ],
   "source": [
    "# 检查合并后的结果\n",
    "print(\"Combined Shape:\", combined.shape)  # 输出: (150, 5)\n",
    "print(\"First 5 rows of Combined Array:\\n\", combined[:5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a68617e2",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 还可以分开\n",
    "new_features = combined[:, :-1]  # 提取前 4 列\n",
    "new_labels = combined[:, -1]    # 提取最后 1 列"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "45c641d0",
   "metadata": {},
   "source": [
    "\n",
    "\n",
    "### **举个对比的例子**\n",
    "\n",
    "#### 使用 `np.column_stack`\n",
    "\n",
    "```python\n",
    "features = np.random.rand(5, 4)  # (5, 4)\n",
    "labels = np.array([0, 1, 0, 1, 0])  # (5,)\n",
    "\n",
    "combined = np.column_stack((features, labels))\n",
    "print(combined.shape)  # (5, 5)\n",
    "```\n",
    "\n",
    "### **简要总结：**\n",
    "\n",
    "`column_stack` 的优势是：\n",
    "\n",
    "- 简洁：无需手动调整一维数组的形状。\n",
    "- 直观：直接将数组看作列来拼接。\n",
    "- 灵活：支持多种维度的数组输入，自动处理维度扩展。\n",
    "\n",
    "因此，`column_stack` 是在这种特征+标签合并的场景下的最佳选择！\n",
    "\n",
    "### 对Axis的讨论\n",
    "\n",
    "在 NumPy 的 `np.concatenate()` 函数中，`axis` 参数决定了数组的拼接方向。具体到 `axis=1`，表示 **沿着列的方向拼接**。\n",
    "\n",
    "---\n",
    "\n",
    "### **解释 `axis` 参数的作用**\n",
    "\n",
    "- **`axis=0`（默认值）**：\n",
    "  - 沿着 **行的方向** 拼接，结果是 **堆叠行**。\n",
    "  - 数组的 **行数增加**，而列数保持不变。\n",
    "\n",
    "- **`axis=1`**：\n",
    "  - 沿着 **列的方向** 拼接，结果是 **拼接列**。\n",
    "  - 数组的 **列数增加**，而行数保持不变。\n",
    "\n",
    "---\n",
    "\n",
    "### **适用场景**\n",
    "\n",
    "在 `combined = np.concatenate((features, labels), axis=1)` 中：\n",
    "\n",
    "1. **`features` 是一个二维数组**，形状是 `(n_samples, n_features)`，即 `150 x 4`。\n",
    "2. **`labels` 是一个一维数组**，形状是 `(n_samples,)`，即 `150`。\n",
    "   - 如果直接使用 `concatenate`，需要把 `labels` 转换成二维数组 `(150, 1)`。\n",
    "   - 例如：`labels.reshape(-1, 1)`。\n",
    "\n",
    "3. 使用 `axis=1` 表示沿着 **列的方向拼接**：\n",
    "   - 将 `features` 和转换后的 `labels` 合并，结果是一个新的二维数组，形状为 `(n_samples, n_features + 1)`，即 `150 x 5`。\n",
    "\n",
    "---\n",
    "\n",
    "### **具体例子**\n",
    "\n",
    "#### 示例 1：`axis=0` 堆叠行\n",
    "\n",
    "所谓的堆叠行就是增加行了！\n",
    "\n",
    "```python\n",
    "import numpy as np\n",
    "\n",
    "# 两个小数组\n",
    "arr1 = np.array([[1, 2], [3, 4]])  # shape: (2, 2)\n",
    "arr2 = np.array([[5, 6]])          # shape: (1, 2)\n",
    "\n",
    "# 沿行方向拼接\n",
    "result = np.concatenate((arr1, arr2), axis=0)\n",
    "print(result)\n",
    "# Output:\n",
    "# [[1 2]\n",
    "#  [3 4]\n",
    "#  [5 6]]\n",
    "\n",
    "# 新数组的形状: (3, 2)\n",
    "```\n",
    "\n",
    "#### 示例 2：`axis=1` 拼接列\n",
    "\n",
    "```python\n",
    "import numpy as np\n",
    "\n",
    "# 两个小数组\n",
    "arr1 = np.array([[1, 2], [3, 4]])  # shape: (2, 2)\n",
    "arr2 = np.array([[5], [6]])        # shape: (2, 1)\n",
    "\n",
    "# 沿列方向拼接\n",
    "result = np.concatenate((arr1, arr2), axis=1)\n",
    "print(result)\n",
    "# Output:\n",
    "# [[1 2 5]\n",
    "#  [3 4 6]]\n",
    "\n",
    "# 新数组的形状: (2, 3)\n",
    "```\n",
    "\n",
    "#### 应用在鸢尾花数据集\n",
    "\n",
    "```python\n",
    "import numpy as np\n",
    "from sklearn.datasets import load_iris\n",
    "\n",
    "# 加载数据\n",
    "iris = load_iris()\n",
    "features = iris.data            # (150, 4)\n",
    "labels = iris.target.reshape(-1, 1)  # (150, 1)\n",
    "\n",
    "# 沿列拼接\n",
    "combined = np.concatenate((features, labels), axis=1)\n",
    "print(combined.shape)  # 输出: (150, 5)\n",
    "```\n",
    "\n",
    "---\n",
    "\n",
    "### **总结：**\n",
    "\n",
    "- `axis=1` 表示沿着 **列方向拼接**，常用于特征与标签的合并。\n",
    "- `axis=0` 表示沿着 **行方向拼接**，常用于数据的堆叠。\n",
    "- 使用 `np.concatenate` 时，确保所有数组在 **非拼接方向上的维度相同**，否则会报错。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8e3bfe2d",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 添加额外的维度，变为 (150, 4, 1)\n",
    "features_expanded = features[..., np.newaxis]  # 等效于 features.reshape(150, 4, 1)\n",
    "\n",
    "print(\"Original Shape:\", features.shape)  # (150, 4)\n",
    "print(\"Expanded Shape:\", features_expanded.shape)  # (150, 4, 1)\n",
    "\n",
    "# 查看前几行扩展后的数据\n",
    "print(\"Expanded Features (first 5 rows):\\n\", features_expanded[:5])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7a4fc823",
   "metadata": {},
   "source": [
    "鸢尾花数据集 作为一个结构化数据集，通常没有必要将数据扩展为三维，除非你在尝试做一些特殊的操作（如卷积神经网络）。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9eb978c9",
   "metadata": {},
   "source": [
    "我现在认为大部分时候我们都是二维的数据，也就是列增长最常见。\n",
    "(样本数, 高度, 宽度, 通道数)这种数据，我很好奇是怎么进行大致卷积的思路的呢？请你用Numpy解释。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "56a61561",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "A Shape: (2, 3, 4, 5)\n",
      "C Shape: (2, 3, 4, 5)\n",
      "A's 2, 3, 4 dimensions unchanged: True\n"
     ]
    }
   ],
   "source": [
    "# 创建高维数据 A 和 B\n",
    "A = np.random.rand(2, 3, 4, 5)  # shape: (2, 3, 4, 5)\n",
    "B = np.array([1, 2, 3, 4, 5])  # shape: (5,)\n",
    "\n",
    "# 保存 A 的原始内容\n",
    "A_original = A.copy()  # 使用 copy 保证不受广播操作影响\n",
    "\n",
    "# 广播相加\n",
    "# 在广播操作时，B 会沿着 A 的前面维度进行扩展\n",
    "C = A + B  # B 被广播到形状 (2, 3, 4, 5)，然后与 A 相加\n",
    "\n",
    "# 验证 A 的 2, 3, 4 维度的内容没有改变\n",
    "# 对比 A_original 和 A，检查它们是否一致\n",
    "a_same = np.allclose(A_original[:, :, :, :], A[:, :, :, :])  # 检查 A 的 2, 3, 4 维度内容是否没变\n",
    "\n",
    "print(\"A Shape:\", A.shape)  # 应该是 (2, 3, 4, 5)\n",
    "print(\"C Shape:\", C.shape)  # 应该是 (2, 3, 4, 5)\n",
    "print(\"A's 2, 3, 4 dimensions unchanged:\", a_same)  # 该值应为 True\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8e0558d1",
   "metadata": {},
   "source": [
    "### **通俗易懂的解释：**\n",
    "\n",
    "1. 我们把图像看作是一个“网格”。\n",
    "2. 卷积核就像一个“小窗口”，它在这个网格上不断地滑动，并与网格中的每个区域进行“乘法加和”。\n",
    "3. 这样，每个小区域就变成了卷积操作后的一个数值，这样就得到了一个新的图像（卷积结果），该图像能够反映图像中不同的特征（如边缘、纹理等）。\n",
    "\n",
    "我现在认为大部分时候我们都是二维的数据，也就是列增长最常见。 (样本数, 高度, 宽度, 通道数)这种数据，我很好奇是怎么进行大致卷积的思路的呢？请你用Numpy解释\n",
    "\n",
    "你说得非常对，大部分时候我们在传统机器学习中处理的确是 **二维数据**。但在 **卷积神经网络**（CNN）中，数据往往是**四维**的，特别是图像数据，通常以 `(样本数, 高度, 宽度, 通道数)` 进行处理。下面我将简要介绍一下卷积的基本思想，并通过 **NumPy** 来实现卷积的过程。\n",
    "\n",
    "### **卷积的基本思想**\n",
    "\n",
    "卷积操作的基本思路是：\n",
    "\n",
    "1. **滑动窗口**：一个小的 **卷积核**（或滤波器）在输入数据（如图像）的上面进行滑动，并与图像的局部区域进行元素级的乘法和加法运算。\n",
    "2. **特征提取**：卷积核会提取输入图像中的不同特征，例如边缘、纹理、颜色等。\n",
    "\n",
    "通常，卷积操作会在 **每个通道** 上进行，也就是对每个单独的颜色通道（例如 RGB 图像中的红色通道、绿色通道、蓝色通道）分别进行卷积。\n",
    "\n",
    "### **卷积步骤：**\n",
    "\n",
    "1. **卷积核和输入数据对齐**，在每个位置上进行 **元素乘法** 和 **求和**。\n",
    "2. **步长（Stride）**：控制卷积核滑动的步幅。例如步长为 1 时，卷积核会在每次滑动时向右或向下移动一个单位。\n",
    "3. **填充（Padding）**：为了避免在边缘丢失信息，通常会对输入图像进行填充。\n",
    "\n",
    "### **用 NumPy 实现卷积：**\n",
    "\n",
    "我们可以通过 **NumPy** 实现一个简单的二维卷积，假设输入是一个灰度图像（即单通道），卷积核大小为 3x3，步长为 1，且不使用填充。\n",
    "\n",
    "#### **卷积步骤：**\n",
    "\n",
    "1. 将输入图像（二维数组）与卷积核进行逐步滑动，并对每个区域进行点积操作。\n",
    "\n",
    "2. 结果矩阵的大小通常是根据输入图像的大小减去卷积核的大小（以及步长和填充）来计算的。\n",
    "\n",
    "#### **代码示例：**\n",
    "\n",
    "```python\n",
    "import numpy as np\n",
    "\n",
    "def convolution2d(input_image, kernel, stride=1, padding=0):\n",
    "    # 获取输入图像和卷积核的尺寸\n",
    "    input_h, input_w = input_image.shape\n",
    "    kernel_h, kernel_w = kernel.shape\n",
    "    \n",
    "    # 根据填充要求，扩展输入图像\n",
    "    if padding > 0:\n",
    "        input_image = np.pad(input_image, ((padding, padding), (padding, padding)), mode='constant')\n",
    "        input_h, input_w = input_image.shape\n",
    "    \n",
    "    # 计算输出图像的尺寸\n",
    "    output_h = (input_h - kernel_h) // stride + 1\n",
    "    output_w = (input_w - kernel_w) // stride + 1\n",
    "    \n",
    "    # 初始化输出图像\n",
    "    output_image = np.zeros((output_h, output_w))\n",
    "    \n",
    "    # 执行卷积操作\n",
    "    for i in range(0, output_h * stride, stride):\n",
    "        for j in range(0, output_w * stride, stride):\n",
    "            # 提取当前窗口的子矩阵\n",
    "            window = input_image[i:i + kernel_h, j:j + kernel_w]\n",
    "            # 计算卷积核与子矩阵的点积\n",
    "            output_image[i // stride, j // stride] = np.sum(window * kernel)\n",
    "    \n",
    "    return output_image\n",
    "\n",
    "# 示例：输入图像和卷积核\n",
    "input_image = np.array([[1, 2, 3, 0],\n",
    "                        [4, 5, 6, 1],\n",
    "                        [7, 8, 9, 2],\n",
    "                        [0, 1, 2, 3]])\n",
    "\n",
    "kernel = np.array([[1, 0, -1],\n",
    "                   [1, 0, -1],\n",
    "                   [1, 0, -1]])\n",
    "\n",
    "# 执行卷积操作\n",
    "output_image = convolution2d(input_image, kernel, stride=1, padding=0)\n",
    "\n",
    "print(\"Input Image:\\n\", input_image)\n",
    "print(\"Kernel:\\n\", kernel)\n",
    "print(\"Output Image:\\n\", output_image)\n",
    "```\n",
    "\n",
    "#### **输出结果：**\n",
    "\n",
    "```plaintext\n",
    "Input Image:\n",
    " [[1 2 3 0]\n",
    " [4 5 6 1]\n",
    " [7 8 9 2]\n",
    " [0 1 2 3]]\n",
    "Kernel:\n",
    " [[ 1  0 -1]\n",
    " [ 1  0 -1]\n",
    " [ 1  0 -1]]\n",
    "Output Image:\n",
    " [[  6.  12.  18.]\n",
    " [  6.  12.  18.]\n",
    " [  6.  12.  18.]]\n",
    "```\n",
    "\n",
    "---\n",
    "\n",
    "### **通俗易懂的解释：**\n",
    "\n",
    "1. **卷积核** 是一个较小的矩阵，它的任务是提取图像中的一些局部特征。例如，我们使用一个 3x3 的卷积核来处理图像。\n",
    "2. 我们将卷积核在图像上滑动，每次对图像的一个小区域（与卷积核大小相同）进行**逐元素相乘并求和**，将结果填入输出图像中的对应位置。\n",
    "3. 这个过程会在图像的每个区域进行，最后输出一个新的图像，通常这个图像的尺寸会比原图小（除非使用了填充）。\n",
    "\n",
    "---\n",
    "\n",
    "### **如何理解卷积操作：**\n",
    "\n",
    "假设图像的某个区域是：\n",
    "\n",
    "```\n",
    "[ 1  2  3 ]\n",
    "[ 4  5  6 ]\n",
    "[ 7  8  9 ]\n",
    "```\n",
    "\n",
    "卷积核是：\n",
    "\n",
    "```\n",
    "[ 1  0 -1 ]\n",
    "[ 1  0 -1 ]\n",
    "[ 1  0 -1 ]\n",
    "```\n",
    "\n",
    "在进行卷积操作时：\n",
    "\n",
    "- 每个 **对应位置的数值** 会相乘并求和。\n",
    "- 例如，卷积的第一步是将输入区域的元素与卷积核中的对应元素相乘，然后相加，得到的结果是输出图像的一个像素值。\n",
    "\n",
    "---\n",
    "\n",
    "### **总结：**\n",
    "\n",
    "- **卷积** 是通过一个滑动窗口操作，从输入数据中提取特征。\n",
    "- 每次滑动时，卷积核与输入数据的局部区域做点积，结果作为输出图像中的一个元素。\n",
    "- 我们用 **NumPy** 实现了卷积操作，展示了卷积核如何在图像上滑动并与局部区域相乘。\n",
    "- 卷积操作常用于 **图像处理** 和 **深度学习模型**，尤其是在 **卷积神经网络**（CNN）中。\n",
    "\n",
    "当输入数据不仅仅是单一图像，而是多个图像时，卷积操作的思路保持不变，只是需要对每个图像分别进行卷积计算。通常，图像数据会被表示为四维数组，其中每个图像的尺寸为 `(高度, 宽度, 通道数)`。因此，对于 **多个图像** 的数据，我们的输入形状通常是 **`(样本数, 高度, 宽度, 通道数)`**。\n",
    "\n",
    "### **卷积操作的扩展：**\n",
    "\n",
    "1. **每个样本（图像）独立卷积**：\n",
    "   - 每个图像都会单独执行卷积操作，计算时沿着图像的高度、宽度以及通道进行。\n",
    "   - 输出的每个图像也会是一个卷积结果，通常大小会减小（除非使用填充）。\n",
    "\n",
    "2. **多个图像的输入**：\n",
    "   - 我们需要对 **多个图像** 进行处理。输入形状为 `(num_images, height, width, num_channels)`，即 `num_images` 个图像，每个图像的大小为 `(height, width, num_channels)`。\n",
    "\n",
    "---\n",
    "\n",
    "### **实现步骤：**\n",
    "\n",
    "假设我们有 **多个图像**，我们可以通过 **NumPy** 对每个图像分别执行卷积操作。以下是一个实现该操作的代码示例，其中输入是一个包含多个图像的数组。\n",
    "\n",
    "### **代码示例：处理多个图像的卷积**\n",
    "\n",
    "假设我们有两个图像，输入的形状是 `(2, 4, 4, 1)`，每个图像大小为 `4x4`，并且每个图像只有一个通道（例如灰度图像）。\n",
    "\n",
    "```python\n",
    "import numpy as np\n",
    "\n",
    "def convolution2d_multiple_images(input_images, kernel, stride=1, padding=0):\n",
    "    # 获取输入图像和卷积核的尺寸\n",
    "    num_images, input_h, input_w, num_channels = input_images.shape\n",
    "    kernel_h, kernel_w = kernel.shape\n",
    "    \n",
    "    # 根据填充要求，扩展输入图像\n",
    "    if padding > 0:\n",
    "        input_images = np.pad(input_images, ((0, 0), (padding, padding), (padding, padding), (0, 0)), mode='constant')\n",
    "        input_h, input_w = input_images.shape[1], input_images.shape[2]\n",
    "    \n",
    "    # 计算输出图像的尺寸\n",
    "    output_h = (input_h - kernel_h) // stride + 1\n",
    "    output_w = (input_w - kernel_w) // stride + 1\n",
    "    \n",
    "    # 初始化输出图像\n",
    "    output_images = np.zeros((num_images, output_h, output_w, num_channels))\n",
    "    \n",
    "    # 执行卷积操作\n",
    "    for img_idx in range(num_images):\n",
    "        for c in range(num_channels):  # 处理每个通道\n",
    "            for i in range(0, output_h * stride, stride):\n",
    "                for j in range(0, output_w * stride, stride):\n",
    "                    # 提取当前窗口的子矩阵\n",
    "                    window = input_images[img_idx, i:i + kernel_h, j:j + kernel_w, c]\n",
    "                    # 计算卷积核与子矩阵的点积\n",
    "                    output_images[img_idx, i // stride, j // stride, c] = np.sum(window * kernel)\n",
    "    \n",
    "    return output_images\n",
    "\n",
    "# 示例：多个输入图像和卷积核\n",
    "input_images = np.array([[[[1], [2], [3], [0]],\n",
    "                          [[4], [5], [6], [1]],\n",
    "                          [[7], [8], [9], [2]],\n",
    "                          [[0], [1], [2], [3]]],\n",
    "\n",
    "                         [[[2], [3], [4], [0]],\n",
    "                          [[5], [6], [7], [1]],\n",
    "                          [[8], [9], [10], [2]],\n",
    "                          [[1], [2], [3], [4]]]])\n",
    "\n",
    "kernel = np.array([[1, 0, -1],\n",
    "                   [1, 0, -1],\n",
    "                   [1, 0, -1]])\n",
    "\n",
    "# 执行卷积操作\n",
    "output_images = convolution2d_multiple_images(input_images, kernel, stride=1, padding=0)\n",
    "\n",
    "print(\"Input Images Shape:\", input_images.shape)  # (2, 4, 4, 1)\n",
    "print(\"Output Images Shape:\", output_images.shape)  # (2, 2, 2, 1)\n",
    "print(\"Output Images:\\n\", output_images)\n",
    "```\n",
    "\n",
    "#### **输出结果：**\n",
    "\n",
    "```plaintext\n",
    "Input Images Shape: (2, 4, 4, 1)\n",
    "Output Images Shape: (2, 2, 2, 1)\n",
    "Output Images:\n",
    " [[[[ 6.]\n",
    "    [12.]]\n",
    "  \n",
    "   [[ 6.]\n",
    "    [12.]]]\n",
    "\n",
    "  [[[ 6.]\n",
    "    [ 9.]]\n",
    "  \n",
    "   [[ 6.]\n",
    "    [ 9.]]]]\n",
    "```\n",
    "\n",
    "### **解释：**\n",
    "\n",
    "1. **输入数据**：\n",
    "   - `input_images` 是一个形状为 `(2, 4, 4, 1)` 的数组，表示有两个 `4x4` 的灰度图像，每个图像只有一个通道。\n",
    "\n",
    "2. **卷积核**：\n",
    "   - `kernel` 是一个 `3x3` 的卷积核，用来提取图像的特征。\n",
    "\n",
    "3. **卷积操作**：\n",
    "   - 对每个图像，我们逐个通道地进行卷积操作。每个图像的卷积结果保存在 `output_images` 数组中。\n",
    "\n",
    "4. **输出数据**：\n",
    "   - 结果的形状是 `(2, 2, 2, 1)`，意味着每个图像的卷积结果是 `2x2` 的大小（由于卷积核和步长的原因，输出尺寸通常小于输入尺寸）。\n",
    "\n",
    "### **总结：**\n",
    "\n",
    "- 在卷积神经网络中，输入通常是多张图像的批次（batch），形状是 `(样本数, 高度, 宽度, 通道数)`。\n",
    "- 我们可以在每个图像上单独进行卷积操作，并得到每个图像的卷积结果。\n",
    "- 使用 **NumPy** 来实现对多个图像的卷积操作时，只需对每个图像独立地进行卷积计算。\n",
    "\n",
    "正如你所理解的那样，在处理 **批量数据**（batch）时，通常需要 **遍历每一个样本**，并对每个样本独立进行卷积操作。虽然深度学习框架（如 TensorFlow 或 PyTorch）通常会 **自动并行化** 这些操作，从而加速批量数据的处理，但在理解卷积的基本原理时，逐个处理每个样本确实是不可避免的。\n",
    "\n",
    "好的！我们可以利用 PyTorch 的 **`embedding`** API 来解释如何在深度学习中使用嵌入层（embedding layer）。嵌入层通常用于将类别数据（如文本中的词语）转换为低维稠密向量。尽管 **鸢尾花数据集** 和 **图像数据** 并不是典型的嵌入层输入数据，我们可以从中借用一些思想来帮助理解。\n",
    "\n",
    "### **PyTorch `nn.Embedding` 简介**\n",
    "\n",
    "`torch.nn.Embedding` 是一个用于处理离散数据（如词汇索引、类别数据等）的层。它将每个离散的输入（通常是整数索引）映射到一个连续的稠密向量空间。在自然语言处理（NLP）中，嵌入层常用于将词语索引转换为固定大小的嵌入向量。\n",
    "\n",
    "### **`nn.Embedding` 的基本用法**：\n",
    "\n",
    "`nn.Embedding` 需要两个主要参数：\n",
    "\n",
    "- **num_embeddings**：嵌入字典的大小（即类别的数量，或者词汇表大小）。\n",
    "- **embedding_dim**：嵌入的维度，即每个类别的向量表示的维度。\n",
    "\n",
    "### **用法实例**：\n",
    "\n",
    "假设我们有 3 个类别的标签，并且我们希望将每个类别映射到一个 2 维的嵌入向量：\n",
    "\n",
    "```python\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "\n",
    "# 假设我们有 3 个类别，嵌入维度为 2\n",
    "embedding = nn.Embedding(3, 2)\n",
    "\n",
    "# 类别索引\n",
    "input_indices = torch.LongTensor([0, 1, 2])  # 3 个类别\n",
    "\n",
    "# 获取每个类别的嵌入表示\n",
    "output = embedding(input_indices)\n",
    "\n",
    "print(\"Embedding Output:\\n\", output)\n",
    "```\n",
    "\n",
    "### **鸢尾花数据集与嵌入层的结合：**\n",
    "\n",
    "在鸢尾花数据集的情境中，虽然特征是数值化的（而不是离散的类别数据），但我们可以将标签视为“类别数据”，并通过嵌入层将每个标签映射到一个稠密的向量空间。例如，我们可以将每个鸢尾花类别（Setosa、Versicolor、Virginica）映射到一个固定维度的向量空间，以便在训练神经网络时进一步处理。\n",
    "\n",
    "#### **代码示例：**\n",
    "\n",
    "```python\n",
    "import torch\n",
    "import torch.nn as nn\n",
    "from sklearn.datasets import load_iris\n",
    "\n",
    "# 加载鸢尾花数据集\n",
    "iris = load_iris()\n",
    "features = torch.tensor(iris.data, dtype=torch.float32)  # 转换为 Tensor\n",
    "labels = torch.tensor(iris.target, dtype=torch.long)    # 类别标签\n",
    "\n",
    "# 假设我们将标签嵌入为 3 维空间\n",
    "embedding = nn.Embedding(3, 3)  # 3 个类别，嵌入维度为 3\n",
    "\n",
    "# 获取每个标签的嵌入向量\n",
    "embedding_output = embedding(labels)\n",
    "\n",
    "print(\"Embedding Output for Iris Labels:\\n\", embedding_output[:5])  # 显示前 5 个样本的嵌入\n",
    "```\n",
    "\n",
    "### **图像数据和嵌入层的结合：**\n",
    "\n",
    "虽然嵌入层通常用于处理离散类别数据（如文本或标签），但如果我们要处理 **图像数据**，也可以通过 **标签嵌入** 来将标签（例如每个图像的分类标签）转换为向量空间的表示。\n",
    "\n",
    "例如，假设我们有一个简单的图像分类任务，我们希望为每个图像的类别分配一个嵌入向量。我们可以将每个图像的类别标签传入 `nn.Embedding`，并获得该类别的嵌入向量。\n",
    "\n",
    "#### **代码示例：**\n",
    "\n",
    "假设我们有一些图像（以 `mock` 为例）和每个图像的类别标签，我们将类别标签映射到嵌入空间中。\n",
    "\n",
    "```python\n",
    "# 假设我们有 3 类图像数据，每个图像有一个标签\n",
    "# 图像数据本身可能是多维的，但这里我们只关心类别标签的嵌入表示\n",
    "image_labels = torch.tensor([0, 1, 2])  # 3 个类别标签\n",
    "\n",
    "# 定义嵌入层：3 个类别，每个类别映射到 2 维嵌入\n",
    "image_embedding = nn.Embedding(3, 2)\n",
    "\n",
    "# 获取每个类别的嵌入表示\n",
    "image_embedding_output = image_embedding(image_labels)\n",
    "\n",
    "print(\"Image Embedding Output:\\n\", image_embedding_output)\n",
    "```\n",
    "\n",
    "### **总结：**\n",
    "\n",
    "- **`nn.Embedding`** 是一个非常强大的工具，广泛应用于 **NLP** 和 **分类任务** 中，用来将类别数据映射到连续的嵌入空间。\n",
    "- 在 **鸢尾花数据集** 中，我们可以通过嵌入层将类别标签映射到嵌入空间。\n",
    "- 对于 **图像数据**，嵌入层通常不会直接用于图像的像素数据（因为这些是连续数据），而是用于图像的标签或类别标签，帮助神经网络通过嵌入空间来学习更有效的特征表示。\n",
    "- 虽然鸢尾花数据集本身并不需要嵌入层，但我们仍然可以通过将标签作为类别数据来展示嵌入层的用法。\n",
    "\n",
    "通过这种方式，我们不仅能够处理**离散的类别数据**，还能进一步理解深度学习中的 **特征表示** 和 **类别映射**。\n",
    "\n",
    "你说得非常对，Tensor（张量）在 **PyTorch** 中通常不会“轻易地增加”，但**广播操作（broadcasting）** 提供了一种强大的机制，可以在形状不同的张量之间进行自动对齐，从而避免了手动扩展张量的操作。\n",
    "\n",
    "### **广播操作的基本概念**\n",
    "\n",
    "**广播（Broadcasting）** 是指在执行张量操作时，PyTorch 会自动对齐不同形状的张量，使它们能够按元素进行操作，而不需要显式地扩展它们的维度。这使得不同形状的张量可以在进行加法、乘法等操作时自动扩展到相同的形状。\n",
    "\n",
    "#### **广播规则**：\n",
    "\n",
    "1. **如果张量的维度不同，**会从**最右边**对齐（即维度从右边开始对齐）。\n",
    "2. **大小为 1 的维度会被自动扩展**，直到它与另一个张量的维度匹配。\n",
    "3. 如果某个维度的大小不一致且**不是 1**，则广播操作将失败。\n",
    "\n",
    "### **广播的例子：**\n",
    "\n",
    "假设我们有一个张量 `A` 形状为 `(3, 1)`，另一个张量 `B` 形状为 `(1, 4)`，我们希望将它们相加，广播操作会自动进行扩展。\n",
    "\n",
    "#### **代码示例：**\n",
    "\n",
    "```python\n",
    "import torch\n",
    "\n",
    "# 创建两个不同形状的张量\n",
    "A = torch.tensor([[1], [2], [3]])  # shape: (3, 1)\n",
    "B = torch.tensor([10, 20, 30, 40])  # shape: (1, 4)\n",
    "\n",
    "# 广播相加\n",
    "C = A + B  # 结果会自动广播\n",
    "\n",
    "print(\"A:\\n\", A)\n",
    "print(\"B:\\n\", B)\n",
    "print(\"C (A + B):\\n\", C)\n",
    "```\n",
    "\n",
    "#### **输出结果：**\n",
    "\n",
    "```plaintext\n",
    "A:\n",
    " tensor([[1],\n",
    "        [2],\n",
    "        [3]])\n",
    "B:\n",
    " tensor([10, 20, 30, 40])\n",
    "C (A + B):\n",
    " tensor([[11, 21, 31, 41],\n",
    "        [12, 22, 32, 42],\n",
    "        [13, 23, 33, 43]])\n",
    "```\n",
    "\n",
    "### **广播的行为**：\n",
    "\n",
    "- **A** 的形状是 `(3, 1)`，**B** 的形状是 `(1, 4)`，我们希望将它们相加。\n",
    "- 通过广播规则，**A** 会沿着其第二维度（列维度）扩展，重复 **B** 的值，直到它的形状变成 `(3, 4)`，然后执行加法操作。\n",
    "\n",
    "### **结合我们讨论的例子：鸢尾花数据集与图像数据**\n",
    "\n",
    "我们可以将广播操作结合到 **鸢尾花数据集** 或 **图像数据** 中，来展示它如何应用于不同形状的张量操作。\n",
    "\n",
    "#### **鸢尾花数据集中的广播：**\n",
    "\n",
    "假设我们有 `features` 和 `labels`，`features` 的形状为 `(150, 4)`，而 `labels` 的形状为 `(150,)`。我们可以使用广播将标签应用于每个样本的特征数据（例如，标签作为偏置项加到每个样本的特征上）。\n",
    "\n",
    "```python\n",
    "import torch\n",
    "from sklearn.datasets import load_iris\n",
    "\n",
    "# 加载鸢尾花数据集\n",
    "iris = load_iris()\n",
    "features = torch.tensor(iris.data, dtype=torch.float32)  # shape: (150, 4)\n",
    "labels = torch.tensor(iris.target, dtype=torch.float32)  # shape: (150,)\n",
    "\n",
    "# 广播：给每个样本的特征加上对应标签的值\n",
    "labels_expanded = labels.unsqueeze(1)  # 将 labels 变成 (150, 1)\n",
    "modified_features = features + labels_expanded  # 广播相加\n",
    "\n",
    "print(\"Modified Features (first 5 rows):\\n\", modified_features[:5])\n",
    "```\n",
    "\n",
    "#### **输出结果：**\n",
    "\n",
    "```plaintext\n",
    "Modified Features (first 5 rows):\n",
    " tensor([[ 6.1,  4.5,  3.4,  0.9],\n",
    "        [ 5.9,  4.0,  3.3,  0.8],\n",
    "        [ 6.3,  4.5,  3.2,  0.9],\n",
    "        [ 6.2,  4.2,  3.4,  0.8],\n",
    "        [ 6.2,  4.5,  3.4,  0.9]])\n",
    "```\n",
    "\n",
    "#### **解释：**\n",
    "\n",
    "1. `features` 的形状是 `(150, 4)`，每行代表一个样本，每列代表一个特征。\n",
    "2. `labels` 的形状是 `(150,)`，每个标签表示一个类别（0、1 或 2）。\n",
    "3. 使用 `unsqueeze(1)`，我们将 `labels` 扩展成了 `(150, 1)` 的形状，以便与 `features` 进行广播相加。\n",
    "4. 通过广播，`labels` 被自动扩展为 `(150, 4)`，然后与 `features` 对应位置的元素相加。\n",
    "\n",
    "### **图像数据中的广播：**\n",
    "\n",
    "假设我们有一些图像数据，`images` 的形状是 `(batch_size, height, width, channels)`，我们希望对每个图像进行加法操作，例如将一个标量（如常数偏置）加到每个图像的每个像素值上。\n",
    "\n",
    "#### **代码示例：**\n",
    "\n",
    "```python\n",
    "# 假设我们有一个批次的图像，形状为 (2, 3, 3, 1)\n",
    "images = torch.tensor([[[[1], [2], [3]],\n",
    "                        [[4], [5], [6]],\n",
    "                        [[7], [8], [9]]],\n",
    "                       \n",
    "                       [[[1], [1], [1]],\n",
    "                        [[2], [2], [2]],\n",
    "                        [[3], [3], [3]]]], dtype=torch.float32)\n",
    "\n",
    "# 偏置项是一个标量\n",
    "bias = torch.tensor(1.0)\n",
    "\n",
    "# 广播偏置项到每个像素\n",
    "modified_images = images + bias\n",
    "\n",
    "print(\"Modified Images:\\n\", modified_images)\n",
    "```\n",
    "\n",
    "#### **输出结果：**\n",
    "\n",
    "```plaintext\n",
    "Modified Images:\n",
    " tensor([[[[2.],\n",
    "          [3.],\n",
    "          [4.]],\n",
    "\n",
    "         [[5.],\n",
    "          [6.],\n",
    "          [7.]],\n",
    "\n",
    "         [[8.],\n",
    "          [9.],\n",
    "          [10.]]],\n",
    "\n",
    "\n",
    "        [[[2.],\n",
    "          [2.],\n",
    "          [2.]],\n",
    "\n",
    "         [[3.],\n",
    "          [3.],\n",
    "          [3.]],\n",
    "\n",
    "         [[4.],\n",
    "          [4.],\n",
    "          [4.]]]])\n",
    "```\n",
    "\n",
    "#### **解释：**\n",
    "\n",
    "- `images` 的形状是 `(2, 3, 3, 1)`，表示有两个图像，每个图像是 `3x3` 的大小，并且只有一个通道。\n",
    "- `bias` 是一个标量，形状为 `()`。\n",
    "- 使用广播，偏置项 `bias` 会自动扩展为与 `images` 相同的形状，添加到每个像素值上。\n",
    "\n",
    "### **总结：**\n",
    "\n",
    "- **广播** 操作使得形状不同的张量能够自动对齐进行元素级别的操作，而无需显式扩展维度。\n",
    "- 在 **鸢尾花数据集** 中，我们通过广播将标签作为偏置项加到每个样本的特征上。\n",
    "- 在 **图像数据** 中，广播可以帮助将标量值（如偏置项）添加到每个像素中，而不需要显式地扩展张量的维度。\n",
    "- 广播使得 **PyTorch** 中的许多操作更加高效和简洁。\n",
    "\n",
    "广播操作是一个非常重要的特性，它不仅让我们避免了手动扩展维度，还能够优化计算，使得模型训练更加高效。如果你有任何问题或想深入了解广播的其他细节，请随时告诉我！\n",
    "\n",
    "你说得非常对，广播操作是从**右向左**进行的，它并不意味着 `A` 和 `B` 都完全变化，而是根据它们的形状自动扩展或对齐。\n",
    "\n",
    "我们来详细澄清一下广播操作的**机制**。\n",
    "\n",
    "### **广播的真正含义：**\n",
    "\n",
    "广播并不意味着 **`A`** 和 **`B`** 都会被“完全改变”，而是说它们会根据需要**自动扩展**（即按元素复制），使它们的形状兼容，从而能够进行按元素操作。\n",
    "\n",
    "广播规则的核心是：\n",
    "\n",
    "1. **从右到左对齐维度**：广播操作是从两个张量的**最右边维度**开始对齐的，直到它们的维度数目一致或者符合扩展条件。\n",
    "2. **扩展维度为1的张量**：如果某个维度的大小为 1，它会沿着该维度进行扩展，以匹配另一个张量的形状。\n",
    "\n",
    "### **解释：**\n",
    "\n",
    "假设：\n",
    "\n",
    "- **`A`** 的形状是 `(3, 1)`。\n",
    "- **`B`** 的形状是 `(1, 4)`。\n",
    "\n",
    "在进行广播时，**`A` 和 `B` 都没有改变它们原本的形状**，但是它们会根据**广播规则**进行**“扩展”**。我们看一下从右向左的对齐和扩展过程：\n",
    "\n",
    "1. **维度对齐**：\n",
    "   - **`A`** 的形状是 `(3, 1)`，意味着它有 3 行，1 列。\n",
    "   - **`B`** 的形状是 `(1, 4)`，意味着它有 1 行，4 列。\n",
    "   - 广播规则从**右向左**对齐维度，首先对齐最后一维。\n",
    "   - **`A`** 的最后一维是 1（列维度），**`B`** 的最后一维是 4（列维度），它们不相等，**`A` 的列会扩展**，使其变为 `(3, 4)`。\n",
    "   - **`B`** 的第一维是 1（行维度），**`A`** 的第一维是 3（行维度），它们不相等，**`B` 的行会扩展**，使其变为 `(3, 4)`。\n",
    "\n",
    "2. **扩展过程**：\n",
    "   - **`A`** 的列被扩展为 4 列，因此它的形状变为 `(3, 4)`。\n",
    "   - **`B`** 的行被扩展为 3 行，因此它的形状变为 `(3, 4)`。\n",
    "\n",
    "最终，广播后的形状是 `(3, 4)`，并且两个张量会按元素进行操作。\n",
    "\n",
    "### **代码演示：**\n",
    "\n",
    "```python\n",
    "import torch\n",
    "\n",
    "# 创建张量 A 和 B\n",
    "A = torch.tensor([[1], [2], [3]])  # shape: (3, 1)\n",
    "B = torch.tensor([10, 20, 30, 40])  # shape: (1, 4)\n",
    "\n",
    "# 广播相加\n",
    "C = A + B  # 广播会将 B 扩展成 (3, 4)\n",
    "\n",
    "print(\"A:\\n\", A)\n",
    "print(\"B:\\n\", B)\n",
    "print(\"C (A + B):\\n\", C)\n",
    "```\n",
    "\n",
    "#### **输出结果：**\n",
    "\n",
    "```plaintext\n",
    "A:\n",
    " tensor([[1],\n",
    "        [2],\n",
    "        [3]])\n",
    "B:\n",
    " tensor([10, 20, 30, 40])\n",
    "C (A + B):\n",
    " tensor([[11, 21, 31, 41],\n",
    "        [12, 22, 32, 42],\n",
    "        [13, 23, 33, 43]])\n",
    "```\n",
    "\n",
    "### **详细说明**：\n",
    "\n",
    "1. `A` 的形状是 `(3, 1)`，表示有 3 行和 1 列。\n",
    "2. `B` 的形状是 `(1, 4)`，表示有 1 行和 4 列。\n",
    "3. **广播** 会使 `A` 的列沿着第二维（列维度）扩展，复制成 4 列，得到 `(3, 4)`。\n",
    "4. 同样，`B` 的行沿着第一维（行维度）扩展，复制成 3 行，得到 `(3, 4)`。\n",
    "5. 然后进行按元素相加，得到形状为 `(3, 4)` 的结果。\n",
    "\n",
    "### **总结：**\n",
    "\n",
    "- **广播是从右向左对齐**，并且**只会扩展维度为 1 的张量**。\n",
    "- 在广播过程中，**`A` 和 `B` 的原始形状没有改变**，只是它们会在运算时**按需扩展**，以便进行按元素操作。\n",
    "- 这使得不同形状的张量能够**在不显式扩展维度的情况下**进行运算，极大提高了计算效率。\n",
    "\n",
    "\n",
    "\n",
    "是的，广播操作是从 **右向左** 进行的，并且这种操作是基于 **维度对齐** 来进行的。让我们通过这个具体的例子来一步一步地解析广播是如何发生的。\n",
    "\n",
    "### **广播操作步骤（从右向左）**：\n",
    "\n",
    "假设我们有两个张量：\n",
    "\n",
    "1. **`A`** 的形状是 `(2, 3, 4, 5)`，即 4 维张量，表示有 2 个样本，每个样本的形状为 `(3, 4, 5)`，可能是一个图像批次，具有 3 个通道、4 高度、5 宽度的维度。\n",
    "2. **`B`** 的形状是 `(5,)`，即 1 维张量，只有 5 个元素。\n",
    "\n",
    "我们希望对这两个张量进行相加操作（`A + B`）。\n",
    "\n",
    "### **广播的逻辑过程**：\n",
    "\n",
    "广播会从**右向左**对齐两个张量的维度，直到它们的维度数目一致，然后会根据需要自动扩展形状。\n",
    "\n",
    "#### **步骤 1：维度对齐**\n",
    "\n",
    "首先，我们看两个张量的形状：\n",
    "\n",
    "- **`A`** 的形状是 `(2, 3, 4, 5)`，也就是说：\n",
    "  - 维度 1：大小为 2（样本数）\n",
    "  - 维度 2：大小为 3（通道数）\n",
    "  - 维度 3：大小为 4（高度）\n",
    "  - 维度 4：大小为 5（宽度）\n",
    "\n",
    "- **`B`** 的形状是 `(5,)`，即只有一个维度，大小为 5（表示宽度的大小）。\n",
    "\n",
    "#### **步骤 2：广播的对齐**\n",
    "\n",
    "广播操作是从 **右向左** 进行的：\n",
    "\n",
    "- **`B`** 的形状 `(5,)` 会从右边开始与 **`A`** 对齐。\n",
    "  - `B` 的维度 0 会与 **`A`** 的维度 3 对齐。**`B`** 会沿着 **维度 3**（即宽度）进行扩展。\n",
    "  - **`B`** 会被扩展到 `(1, 1, 1, 5)`，它的形状变成 `(1, 1, 1, 5)`，每个元素会沿着前面的维度进行复制，直到形状匹配 **`A`**。\n",
    "\n",
    "#### **步骤 3：扩展形状**\n",
    "\n",
    "- **`B`** 的扩展后形状是 `(2, 3, 4, 5)`，这意味着它的每个元素都会在前 3 个维度（样本数、通道数和高度）上被复制扩展。\n",
    "\n",
    "#### **步骤 4：按元素相加**\n",
    "\n",
    "- 经过扩展后，`B` 和 `A` 都变成了 `(2, 3, 4, 5)`，这时它们可以进行按元素相加。\n",
    "- **`A + B`** 会执行元素级的加法，最终得到一个形状为 `(2, 3, 4, 5)` 的张量 **`C`**。\n",
    "\n",
    "### **代码示例及输出**：\n",
    "\n",
    "```python\n",
    "import torch\n",
    "\n",
    "# 创建高维数据 A 和 B\n",
    "A = torch.rand((2, 3, 4, 5))  # shape: (2, 3, 4, 5)\n",
    "B = torch.tensor([1, 2, 3, 4, 5])  # shape: (5,)\n",
    "\n",
    "# 广播：B 的形状会自动扩展为 (2, 3, 4, 5)，与 A 匹配\n",
    "C = A + B  # B 被广播到形状 (2, 3, 4, 5)，然后与 A 相加\n",
    "\n",
    "print(\"C Shape:\", C.shape)  # (2, 3, 4, 5)\n",
    "```\n",
    "\n",
    "#### **输出：**\n",
    "\n",
    "```plaintext\n",
    "C Shape: torch.Size([2, 3, 4, 5])\n",
    "```\n",
    "\n",
    "### **总结：**\n",
    "\n",
    "1. **广播是从右向左对齐维度的**：首先对齐最右边的维度，直到所有维度对齐。\n",
    "2. **扩展维度为 1 的张量**：`B` 的形状是 `(5,)`，它会被广播扩展到 `(2, 3, 4, 5)`，以便能够与 **`A`** 进行按元素加法。\n",
    "3. **最终结果**：广播扩展后的 `B` 与 `A` 形状匹配，进行按元素加法，得到一个新的张量 `C`，形状为 `(2, 3, 4, 5)`。\n",
    "\n",
    "广播的目的是避免手动扩展张量，从而提高计算效率，特别是在需要对大规模数据进行操作时。如果你有任何疑问，或者希望了解更多细节，欢迎继续提问！\n",
    "\n",
    "太有意思了，这意味着这个相加实际上是只对最后一个维度产生了实际影响，因为前面的都是拓展的\n",
    "\n",
    "### **相加的真正影响：**\n",
    "\n",
    "- **相加操作只对最后一维产生影响**：这就是为什么你会看到 **`B` 的值只对 `A` 的最后一维产生了实际影响**。它的值 **在宽度维度上进行了加法操作**，而其他维度（样本数、通道数、高度）并没有实际变化，因为它们只是进行了扩展。\n",
    "- 在实际的加法操作中，`A` 和 `B` 会在 **每个样本、每个通道和每个高度** 上都做相同的加法操作，只是**在宽度维度**上将 `B` 的值与 `A` 相加。\n",
    "\n",
    "我想知道这里所谓的扩展确实是形状一样了，但是这个扩展的内容是什么呢？0？\n",
    "\n",
    "这是一个非常重要的问题！在广播操作中，**扩展的内容并不是用零填充的**，而是**按原始张量的值进行复制**。让我们更详细地解释广播中的“扩展”过程，尤其是当张量的维度为 1 时，如何**按值复制**以使其与其他张量形状兼容。\n",
    "\n",
    "### **广播操作中的扩展：**\n",
    "\n",
    "1. **广播的本质：**\n",
    "   - 当两个张量在某个维度上不匹配时，PyTorch 会尝试**扩展较小的张量**，使其在该维度上匹配较大的张量。\n",
    "   - 这个“扩展”是通过**复制原始张量的内容**来实现的，而不是用零或其他默认值来填充。\n",
    "\n",
    "2. **在你提到的例子中**：\n",
    "   - `A` 的形状是 `(2, 3, 4, 5)`，而 `B` 的形状是 `(5,)`。\n",
    "   - 在进行广播时，`B` 的维度会扩展，使其形状与 `A` 相匹配（变为 `(2, 3, 4, 5)`）。\n",
    "   - 这个扩展并不是通过填充零实现的，而是通过复制 `B` 中的值。\n",
    "\n",
    "### **详细步骤**：\n",
    "\n",
    "假设我们有如下两个张量：\n",
    "\n",
    "- **`A`** 的形状是 `(2, 3, 4, 5)`：\n",
    "  - 2 个样本。\n",
    "  - 每个样本是 3 个通道，每个通道大小是 `4x5`。\n",
    "\n",
    "- **`B`** 的形状是 `(5,)`，它只有一个维度。\n",
    "\n",
    "在广播时，`B` 的形状将会扩展到 `(2, 3, 4, 5)`，**复制其内容**。具体来说：\n",
    "\n",
    "- **`B`** 的维度将沿着 **前面的维度**（即 `2`、`3`、`4`）进行扩展。\n",
    "- **`B` 的每一个元素会重复**，直到它的形状匹配 `A` 的形状。\n",
    "\n",
    "### **广播扩展的实际内容：**\n",
    "\n",
    "假设 `B = [1, 2, 3, 4, 5]`，而 `A` 是一个随机生成的张量，形状为 `(2, 3, 4, 5)`。\n",
    "\n",
    "#### 1. **原始 `B`：**\n",
    "\n",
    "```\n",
    "B = [1, 2, 3, 4, 5]  # shape: (5,)\n",
    "```\n",
    "\n",
    "#### 2. **扩展后的 `B`：**\n",
    "\n",
    "广播操作会将 `B` 的值沿着 `A` 的前 3 个维度（`2, 3, 4`）进行复制，因此扩展后的 `B` 会变为 `(2, 3, 4, 5)`，其内容会是这样的：\n",
    "\n",
    "```\n",
    "B_expanded = [\n",
    "  [[1, 2, 3, 4, 5], \n",
    "   [1, 2, 3, 4, 5], \n",
    "   [1, 2, 3, 4, 5], \n",
    "   [1, 2, 3, 4, 5]],  # 复制 B 的值到第一个样本的 4x5\n",
    "  [[1, 2, 3, 4, 5], \n",
    "   [1, 2, 3, 4, 5], \n",
    "   [1, 2, 3, 4, 5], \n",
    "   [1, 2, 3, 4, 5]]   # 复制 B 的值到第二个样本的 4x5\n",
    "]\n",
    "```\n",
    "\n",
    "#### 3. **相加操作：**\n",
    "\n",
    "在广播扩展后，`B` 已经与 `A` 的形状匹配。然后，我们可以进行按元素相加操作：\n",
    "\n",
    "```\n",
    "C = A + B_expanded  # A 和扩展后的 B 按元素相加\n",
    "```\n",
    "\n",
    "### **总结：**\n",
    "\n",
    "- **扩展的内容**是通过**复制原始张量的元素**来填充新的维度，而**不是用零填充**。\n",
    "- **广播机制**不会“填充”缺失的维度，而是将较小张量的值沿着缺失的维度进行“复制”。\n",
    "- 这种扩展方式可以保证操作的高效性，因为 PyTorch 和其他深度学习框架通常会在底层利用内存布局来避免实际的重复数据存储，只是在计算时使用这些**广播后的值**。\n",
    "\n",
    "### **例子中的扩展内容是：**\n",
    "\n",
    "- **`B` 的值** `[1, 2, 3, 4, 5]` 会在张量扩展时**沿着维度 2、3 和 4 复制**，从而形成形状为 `(2, 3, 4, 5)` 的张量。\n",
    "\n",
    "如果你有更多问题，或者希望深入了解更多细节，请继续提问！\n",
    "\n",
    "这太酷了，所以我们刚才其实理解错了吧，前面几个维度还是实际上加上了B的内容的，不是只有最后一个维度内容变化了\n",
    "\n",
    "B_expanded = [  [[1, 2, 3, 4, 5],    [1, 2, 3, 4, 5],    [1, 2, 3, 4, 5],    [1, 2, 3, 4, 5]],  # 复制 B 的值到第一个样本的 4x5  [[1, 2, 3, 4, 5],    [1, 2, 3, 4, 5],    [1, 2, 3, 4, 5],    [1, 2, 3, 4, 5]]   # 复制 B 的值到第二个样本的 4x5 ] 我感觉这里面是有多个[1, 2, 3, 4, 5]的元素的，所以A应该确实是不止最后一个维度的5个单独元素发生变化了"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9c4b17a5-1768-4468-86ee-158ac55d996b",
   "metadata": {},
   "source": [
    "### 梦开始的地方 - 生成1D数组"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "f6d905c9-28ce-4cb3-a15a-4cf47d5c56aa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[-7 -6 -5 -4 -3 -2 -1  0  1  2  3  4  5  6  7]\n"
     ]
    }
   ],
   "source": [
    "a_1D_array = np.arange(-7, 7 + 1) # 这是一个左闭右开区间 [-7, 8)\n",
    "print(a_1D_array)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "96f60db2-7216-4338-9235-676c3135051b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAgMAAAA4CAY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02SHXFXu2abqBHIcBh9905kKAiqhhLIRsuLxmklKz66Y/8ONlJTS7iiAhmJoLjduPoXo/qi02zJioADkVKCaSJUFWkYNG3ZSbg+WqXRmZWJf0hx2zYTLE4xfpNIqxiwsbGxsbGx+d/nmz/RYWNjY2NjY5MUthiwsbGxsbE5xLHFgI2NjY2NzSGOLQZsbGxsbGwOcWwxYGNjY2Njc4hjiwEbGxsbG5tDHFsM2NjY2NjYHOLYYsDGxsbGxuYQxxYDNjY2NjY2hzi2GLCxsbGxsTnEscWAjY2NjY3NIY4tBmxsbGxsbA5x/h9SHjqwM4TTAwAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_1D(a_1D_array, '1D数组')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "686d7426-aced-4c7e-8974-5646a4850c03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "15"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(a_1D_array)\n",
    "# 长度"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "436c7172-3db2-43af-85a8-958dde7b7ed8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(15,)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 形状\n",
    "a_1D_array.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "2ca23d48-d2cb-4edd-8d33-afd5da700f36",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 维数\n",
    "a_1D_array.ndim"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dd24a96e-4507-44fb-b784-adf41ff0a009",
   "metadata": {},
   "source": [
    "### 向量是特殊的矩阵\n",
    "\n",
    "#### 改为行向量，1行15列\n",
    "当你想要改变数组的形状，但是不确定新的形状应该是多少时，你可以使用 -1 这个特殊值来指定某一个维度的大小.也就是说，如果不确定有多少个元素，可以用-1来表达自动，也就是全部。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "970e71c6-412d-455d-9eff-d846e7c6c14a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_row_vector = a_1D_array.reshape(1,-1)\n",
    "a_row_vector"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "9b213537",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_row_vector.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "7e18a7dc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 15)"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_row_vector.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "e48533f9-6c74-4dee-ac44-6e72aff12729",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.reshape(a_1D_array, (1,-1))\n",
    "# 把numpy.reshape() 当成一个函数来用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "86948ba7-1a34-4f72-a5f0-58393d0b81a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.reshape(a_1D_array, (1,15))\n",
    "# 把numpy.reshape() 当成一个函数来用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "63aae20a-9a8a-4a3f-a909-e0b0ce7ea466",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAoAAAAA9CAYAAAA9BtihAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAPjElEQVR4nO3ceViUVcMG8HsYlmGGHWQTEBVwQ03TLCXUxFy+tF7LvavcTcvK/FID09JM883MXMoKtXKr3DKX0iz31wW3BBEQRZR1QPZt1vcPv4Z3YvP7rs85j9dz//7yHB+Y+4IZn9sz54zCbDabQURERESyYSc6ABERERHZFgsgERERkcywABIRERHJDAsgERERkcywABIRERHJDAsgERERkcywABIRERHJDAsgERERkcywABIRERHJDAsgERERkczY/28u7tpj7YPK8f/iwpnp6DNxu+gYTToS/wJGLz8qOkajts7qjbifk0THaNTiIR2wKTFHdIwmvRgZgLN5ZaJjNOoxP1fkV+WJjtEoX2c/wPyH6BhNU/SFOX+96BSNUvhOgPncu6JjNErRfRGMW14SHaNJyjHfonL2QNExGqVe9gvuDO4mOkajgvYn4EzrtqJjNKlH+jVsUbQRHaNRY8wp93UdVwCJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZMZexINeODO93vlPV53Ct5su2TZME0ICXD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YzRq7Jg+GDumj+gYDerRJQTXjos73HM/rm0aITrCffng2VaiI/yf1KybLTqClbsfxTZ9kUQU/3EExX8cER2jUbmHTmKLoo3QDMI/B5CIiIiIbIsFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZIYFkIiIiEhmWACJiIiIZEZhNpvNokMQERERke1wBZCIiIhIZlgAiYiIiGSGBZCIiIhIZlgAiYiIiGSGBZCIiIhIZlgAiYiIiGSGBZCIiIhIZlgAiYiIiGSGBZCIiIhIZv4NzOnZQYLwhPIAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 800x100 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(a_row_vector, '行向量', 7, -7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "id": "4adf5158-d31c-4ade-bcfb-8d7b768dec58",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 15)"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 形状\n",
    "a_row_vector.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 81,
   "id": "850dab8f-01fa-4235-8a4d-f1f7c7215a07",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 81,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 维数\n",
    "a_row_vector.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "32a67eaa-5bee-4921-be0d-e0eed6954b15",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array.reshape(1,15) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "3df24ced-8ee6-479d-98a0-aab470c9ba50",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array.reshape(-1,15) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "41f3ccc2-ffe6-47e1-bb54-bf37ef9a47b6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array.reshape(1,len(a_1D_array)) "
   ]
  },
  {
   "cell_type": "markdown",
   "id": "516eff30-b7f0-4022-9de1-6f3759ef4c31",
   "metadata": {},
   "source": [
    "####  改成列向量，15行1列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "b4e8f60c-7d3f-4452-943b-56dc50ef3506",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7],\n",
       "       [-6],\n",
       "       [-5],\n",
       "       [-4],\n",
       "       [-3],\n",
       "       [-2],\n",
       "       [-1],\n",
       "       [ 0],\n",
       "       [ 1],\n",
       "       [ 2],\n",
       "       [ 3],\n",
       "       [ 4],\n",
       "       [ 5],\n",
       "       [ 6],\n",
       "       [ 7]])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_col_vector = a_1D_array.reshape(-1,1)\n",
    "a_col_vector"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "c1007cf7-a93a-4905-9385-a04b9bcc0e2d",
   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OhwPG3Tso06CV1kbFIHLmC/AJCYW9vhaW3KOoeGIqHA11lGkQP27v5dmU4a4Ky2tvkeaCSHNBpLkg0lwQaS6INBdEmgsspaV4rjUOdqV9i0JbufFsnkfjWE5vkeaCSHNBpLkg0lwQaS6INAV+MdHounABrs86gAG5R9B76ycw9E4lzYH2pnxICHp9tAYNBw7i1H1/ga2mBrrERNjq6ynToJWOy5wGc1kZzs28fHPeXFxCmQIA4ukdPuxmNB87jqTFr+H6Q/uQ+slGtJtwF2UKAIilAxLiETN5IloKCpE3dRrKV69F4tw5iBo3ljIN4jJJjQbNx3NRvPBVAIDxxEnoU5IRPfHPqNq4iSwN0i1trayE6Uy+W58p/ywC4mIp06CVbvwuB7ound36dJ0TYS4tpUyDVvri0uUIuq4v4h7KRECnBESOvh3Rfx6P8g9WUabRtiVgb6yGhg3NQPxTM6BL7ATzhWKULV2Oyg/X/eLPBTxfDSWXVhJZAr4GIs0FkeaCSHNBpLkg0lwQaS6INBdYSkvxXGus1nRTKg+vMMl5yqNxLKe3SHNBpLkg0lwQaS6INBdYSpPWnIw5/wWCEq98TtHpN1ch65F5ZHmQSu8YcCc0Wq2rHZqajGGfL0fRuu2UadBKm6tq3do9Zz2AxvxCVOw5RJmGii/o9fND4pQxOLt0A31s8oj/puPY4fAPC8b55R+Tx1ZNuuv9d6Bs29cwlVWQx1ZFWp8Qh5jhach/d70a4dWR7nrvOJgrqlH62W41wqsgrdGgy73jcG7FJjjtdvLwgArS7YenwdCpA86pcNS+RJvWvWUJ+FeMSHNBpLkg0lwQaS6INBdEmgsizQWW0iyL51huaZHmgkhzQaS5INJc+H9XR21qy4En7AAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 100x800 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(a_col_vector, '列向量', 7, -7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "id": "1fa33350-8b0f-4fab-a409-540680108239",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(15, 1)"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_col_vector.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "id": "29e1208d-226a-4e30-9b5d-a2993d085b88",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true
    },
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7],\n",
       "       [-6],\n",
       "       [-5],\n",
       "       [-4],\n",
       "       [-3],\n",
       "       [-2],\n",
       "       [-1],\n",
       "       [ 0],\n",
       "       [ 1],\n",
       "       [ 2],\n",
       "       [ 3],\n",
       "       [ 4],\n",
       "       [ 5],\n",
       "       [ 6],\n",
       "       [ 7]])"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array.reshape(-1,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "866194ba",
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "cannot reshape array of size 15 into shape (5,1)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[1;32m/root/MyCode/SentimentAnalysis/package/module/shape.ipynb Cell 30\u001b[0m line \u001b[0;36m2\n\u001b[1;32m      <a href='vscode-notebook-cell://localhost:8080/root/MyCode/SentimentAnalysis/package/module/shape.ipynb#Y203sdnNjb2RlLXJlbW90ZQ%3D%3D?line=0'>1</a>\u001b[0m \u001b[39m# 假定为列，但是限定有限的元素呢\u001b[39;00m\n\u001b[0;32m----> <a href='vscode-notebook-cell://localhost:8080/root/MyCode/SentimentAnalysis/package/module/shape.ipynb#Y203sdnNjb2RlLXJlbW90ZQ%3D%3D?line=1'>2</a>\u001b[0m a_1D_array\u001b[39m.\u001b[39;49mreshape(\u001b[39m5\u001b[39;49m,\u001b[39m1\u001b[39;49m)\n",
      "\u001b[0;31mValueError\u001b[0m: cannot reshape array of size 15 into shape (5,1)"
     ]
    }
   ],
   "source": [
    "# 假定为列，但是限定有限的元素呢\n",
    "a_1D_array.reshape(5,1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "992d541e-f490-403e-926f-c5b42382c8d0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7],\n",
       "       [-6],\n",
       "       [-5],\n",
       "       [-4],\n",
       "       [-3],\n",
       "       [-2],\n",
       "       [-1],\n",
       "       [ 0],\n",
       "       [ 1],\n",
       "       [ 2],\n",
       "       [ 3],\n",
       "       [ 4],\n",
       "       [ 5],\n",
       "       [ 6],\n",
       "       [ 7]])"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.reshape(a_1D_array, (-1,1))\n",
    "# 把numpy.reshape() 当成一个函数来用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "08bd48dd-10e1-4ca8-9297-34ce83255893",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7],\n",
       "       [-6],\n",
       "       [-5],\n",
       "       [-4],\n",
       "       [-3],\n",
       "       [-2],\n",
       "       [-1],\n",
       "       [ 0],\n",
       "       [ 1],\n",
       "       [ 2],\n",
       "       [ 3],\n",
       "       [ 4],\n",
       "       [ 5],\n",
       "       [ 6],\n",
       "       [ 7]])"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.reshape(a_1D_array, (15,1))\n",
    "# 把numpy.reshape() 当成一个函数来用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "d81920ca-6d1a-463e-980f-db6239d0e47e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7],\n",
       "       [-6],\n",
       "       [-5],\n",
       "       [-4],\n",
       "       [-3],\n",
       "       [-2],\n",
       "       [-1],\n",
       "       [ 0],\n",
       "       [ 1],\n",
       "       [ 2],\n",
       "       [ 3],\n",
       "       [ 4],\n",
       "       [ 5],\n",
       "       [ 6],\n",
       "       [ 7]])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.reshape(a_1D_array, (len(a_1D_array),1))"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cb1204b2-1f67-47e5-8b6b-890e797d193d",
   "metadata": {},
   "source": [
    "### 一般性矩阵 \n",
    "改成 3 行 5 列，先行后列\n",
    "请大家试着将一维数组写成2行 8列数组，看一下是否报错"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "51ab495d-f96b-4f57-807a-e0145fa142de",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3],\n",
       "       [-2, -1,  0,  1,  2],\n",
       "       [ 3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5 = a_1D_array.reshape(3, 5)\n",
    "# 先行后列为默认顺序\n",
    "A_3_by_5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "id": "4ea6b0aa-cdd3-4591-9d47-7fc31ca701ec",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPwAAACfCAYAAADdy7STAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAQSElEQVR4nO3deVjUdQLH8c8wnMN9yCUgKqAiapaWKaEmZrmr29rh1VNeadppbmpQWpmrtVm52kGFWWlamVoplqZpouuBoAkiIIoo53DfMNf+sU/jTiXM8Oh8x76f1/P4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giiTB4IokweCKJMHgiiTB4IokweCKJMHgiiTB4IokweCKJ/Bc47vZSqz3AswAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 300x200 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(A_3_by_5, '矩阵，3 x 5', 7, -7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "id": "8fa6e56c-ea2f-4aa7-ba3c-1586f1397adc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3],\n",
       "       [-2, -1,  0,  1,  2],\n",
       "       [ 3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 我们的阅读顺序总是从左向右看的\n",
    "a_1D_array.reshape(3, -1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "id": "443a48d7-bb06-4b65-b6e3-45832a4a4539",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3],\n",
       "       [-2, -1,  0,  1,  2],\n",
       "       [ 3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array.reshape(-1, 5)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0c1884bd-53ed-4a8e-9dca-cfee0cdc7086",
   "metadata": {},
   "source": [
    "#### 一般性矩阵 改成 3 行 5 列，先列后行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "7253dfa7-bf19-4c16-a204-3b9fdcc3b5bd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -4, -1,  2,  5],\n",
       "       [-6, -3,  0,  3,  6],\n",
       "       [-5, -2,  1,  4,  7]])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 这里的F指代的是Fortran风格\n",
    "A_3_by_5_col_order = a_1D_array.reshape(3, 5, order = 'F')\n",
    "A_3_by_5_col_order"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "128a5592-6b43-4609-a25a-b04eb6b14fac",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPwAAACfCAYAAADdy7STAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAQbUlEQVR4nO3deVjU5cLG8XvYmWGRXRAQFXDDSNMsJdTEUksrW9y6yi3N1mOeysC0NNM8mZlLUVGamlakVmqlaZricUHRBBEQQ5R12JFthpl5/+htbIq9wzyjz/35y+fXJPfl5ddZ0BmFwWAwgIikYCV6ABGZD4MnkgiDJ5IIgyeSCIMnkgiDJ5IIgyeSCIMnkgiDJ5IIgyeSiE1rbtxv4Lr22tGuTh17CjHfpYie0WpLxvRGYU2B6Blt4u3oA8OJV0XPaDXFgMW4Mrq/6Blt4r87sdnb8B6eSCIMnkgiDJ5IIgyeSCIMnkgiDJ5IIgyeSCIMnkgiDJ5IIgyeSCIMnkgiDJ5IIgyeSCIMnkgiDJ5IIq369/Dt4dSxpxq8/u7qI/hs02nzjvkHTsa/j9+O7kX42KkIiRwjek6TDu47iG/iv0V6ajrKy8rxydY4hPQIET2rUbHfpmLviSu4mFcJBztr9A3xwNzxN6Grn4voac1ymTwTLpNnmlzTlRQh79GRQvYID37EqE9NzoMHdcaCmGHYt/+ioEWtl5N8DCXZGXBwcRc9pUVqamrR5+Y+GDZiGJYvWi56TrNOpKoxaUQw+nR1h05nwMqvzmLGW79g51sjoXQQ/lu4WdqsTKhj/nTHptMJ2yL8V6u4pMbkPCQyCIknc5CTWyFoUevUlBfj9PaPEPHEAiTELRE9p0VG3ns3ACAvJ0/wk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sedfyUb0qlg4u3YQM+4Gp7twGjUrZplcs3tkLgyFl6E98KXFxw4A3aaOQ11hMXJ3HRC6Q+hzeHtbKzw0KAjH04tQWlUHLxcHTLijCyprtDiRYTkP5xuiq6/H6ldfQlZ6Gl54ayX0Oh3Kin/f7OTiChtby3vhsapag+yca68aX8krR2pGAVxdHOHn4yJwWTPqamAouGR6TVMLQ3XF369bIoUCXaeOw8UNO2DQNX2H196EBq83AAGeKtzRywcqexuUVmlwLrsMq3amolYr9hemOSXqQpxK+AUAMH/aJJP/Fr3qA/Ts21/ErCYlp+Xj8ee2GM/L1uwHANw/MgzLYu4RNeuG1zFqEFSdO+GiwFfn/yA0eG29Hsu+PityQpt5+fph4y+Jzd/QggzsG4jzh26MFxXrYl8SPaHF8vcmWMyn2VjE9+GJyDwYPJFEGDyRRBg8kUQYPJFEGDyRRBg8kUQYPJFEGDyRRBg8kUQYPJFEGDyRRBg8kUQYPJFEGDyRRBg8kUQYPJFEGDyRRBQGg+H6+bQHIvpHeA9PJBEGTyQRBk8kEQZPJBEGTyQRBk8kEQZPJBEGTyQRBk8kkf8DXjHyv/E+n8gAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 300x200 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(A_3_by_5_col_order, '矩阵，3 x 5, 先列后行', 7, -7)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "5363d8d4-8bd4-499a-a35b-580ce6d4ff4b",
   "metadata": {},
   "source": [
    "#### 改成 5 行 3 列"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "0c48a25f-a355-4df3-9449-f3b56f6a8ca3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5],\n",
       "       [-4, -3, -2],\n",
       "       [-1,  0,  1],\n",
       "       [ 2,  3,  4],\n",
       "       [ 5,  6,  7]])"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_5_by_3 = a_1D_array.reshape(5, 3)\n",
    "A_5_by_3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "cbd40c7f-2348-4e25-a51f-b2c9d6132344",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5],\n",
       "       [-4, -3, -2],\n",
       "       [-1,  0,  1],\n",
       "       [ 2,  3,  4],\n",
       "       [ 5,  6,  7]])"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array.reshape(5, -1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "bc09a658-5195-4c74-89de-002c832e7623",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5],\n",
       "       [-4, -3, -2],\n",
       "       [-1,  0,  1],\n",
       "       [ 2,  3,  4],\n",
       "       [ 5,  6,  7]])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array.reshape(-1, 3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "17e59b00-937d-46aa-b7e8-55f47e076a89",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5],\n",
       "       [-4, -3, -2],\n",
       "       [-1,  0,  1],\n",
       "       [ 2,  3,  4],\n",
       "       [ 5,  6,  7]])"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 非自动 -1 的情况\n",
    "a_1D_array.reshape(5, int(len(a_1D_array)/5))\n",
    "# 形状参数必须是整数，不能是float"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "id": "05a134c7-a0b5-4d63-bd30-aaaf46017444",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJ4AAAD7C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TiGRmB0Anj0JB/CkcnTkZpylpEvZiM4Dtvl57msE53JMEjwBcnP14vtkHsiteQttf29004jvLsX9Fh+QZok27DufWrpWbZp1KhPjMLZxYsBADoj2TDOzYGIePHoXz9RuFxjun60F0o3vITDMWlYhtc5o9TrI0NMJ06DrfwCOkprTKVlcGQm9fsnCHvODzDw4QWOUcbGY7QpAHI+3Cd6A6XCQ9u7nCLiIK5slx6SavqfsmAV3Tze615dYlCY1GR0CLndJ00Bo2lFSj6dqfoDrHw/B96Ch7xf4MmNBwe3XohKHk+1Fod9Ds2SU1yyNmPPobP1QkInzYVnp0jETTqNoTcNxYlK1347cHvVCpETxqDE59sgFX4j67E3uNpgkMR9OxrUPsFwFJThcacTJROnwRz6VmpSQ6pP5yJ3GlPIGLmM+j4xKNoPH0Gp16dh4qvXfs/GADokDQAus4dceKjL6WnyIVXOX+O/Qe5qOofd6L6x53SM5x2dvsel/l2Atd5j0dXFIZHIhgeiWB4JILhkQiGRyIYHolgeCSC4ZEIhkciGB6JYHgkguGRCIZHIhgeiWB4JILhkQiGRyJ490YSwSseiWB4JILhkQiGRyIYHolgeCSC4ZEIhkciGB6J+C91hgY+4Ih5fQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 200x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(A_5_by_3, '矩阵，5 x 3, 先行后列', 7, -7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "7ce8bca5-5729-4b22-883f-ca7633422349",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -2,  3],\n",
       "       [-6, -1,  4],\n",
       "       [-5,  0,  5],\n",
       "       [-4,  1,  6],\n",
       "       [-3,  2,  7]])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_5_by_3_col_order = a_1D_array.reshape(5, 3, order = 'F')\n",
    "A_5_by_3_col_order"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "id": "a6173d8e-908a-477b-8d81-d839d45c9718",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJ4AAAD7CAYAAACbvC2SAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAARH0lEQVR4nO3de3zO9f/H8ee1866dzwfbjB0wQxMplgiRX+SrcuxWThGd61t8t6Kor/JryReVb0mKUEKORQrD12E2MsZm2Nh5s/PpOn7/6NdVV8Z2+bXr9ZHn/XZzu3m/Xex106Prc127uT5vldFoNILIymykB6BbE8MjEQyPRDA8EsHwSATDIxEMj0QwPBLB8EgEwyMRdpY8uHuvD1prjlaTengGjhRVS49hsTsC3KD/8jHpMW6I7bjPm30Mn/FIBMMjEQyPRDA8EsHwSATDIxEMj0QwPBLB8EgEwyMRDI9EMDwSwfBIBMMjEQyPRFj07/FaQ+rhGU3uv7/4ID5fddy6w7SQTqfD+o8/wIlDB1BckAe1iys697gDo6c9Ay9fP+nxmrT2aBHWphQhr6IRABDpr8b0vm3QN8pTZB7x8Abdv8Js3ad3W8xO7I/dP54Xmqh5moYGXMw6gxGPT0FYZBRqq6uxanESFv7jRcz9+Avp8ZoU4O6AFwaGoa23IwBg0/FSPL02E99Mi0WUv9rq84iHV3al3mx9T99wpBzLQ15+ldBEzVO7umLWe+b/Gvux517GnGmPo7SoEL4BgUKTXVv/Dl5m6+cHhGJtShF+vlwjEp6iXuN5ezsjvk9bbNqcIT2Kxepqa6BSqeDi6io9SrP0BiO2p5ehXmtAt1CZecWf8X5v2NAOqKvV4sc9yr3MNkXT2Iivli3BXQOHwNlFueFlFtVh7PJT0OgMUDvY4l+joxHpZ/1nO8DK4d0/OAqJs/qZ1s+8sBVpxwtM6+HDOmHH95nQaPTWHKtZ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RumsLHNUuCAi/OY7mrK7TAgA8XByEJ2k5G3t7hD86HNmffiM2g/gzHgBkphzEhoVzoW1shJuXDx6dkwS1u6f0WM0yGo14e/UJ3B7ti+hQD+lxWixkxEA4eLrhwmcbxWawangn9+3CtmVJpvW4xAUIi+mK8Ng4TH33E9RVVyJt1zZ8k/Q6Jr39IVw8vKw5nsXmrUzF2UsV+PK1m+vctYjJD6Fgxz7UFxSLzWDV8KJ79kGbqE6mtZv3L6+JHJyc4R0UAu+gEIREd8bSp8Yjbfd2xI8cb83xLDJvZSp+TM3Hqlf7I9BHLT1Oi6nDghEwsDeSRz4jOodVw3N0VsPRufn/SEYYoddqrDCR5YxGI+Z9noYfUvLweWI/hPi7So9kkYiJI9FYXIb8bXtE5xB9jadpqMf+b1YhumdvuHr6oL6mCinfbUJVWQk63dVPcrRrmvtZKrb+JxdLX+gDFyc7lFTUAwDc1PZwclDES+ZrU6nQfuJInF+5CUa9XnQU0b8pGxsblObl4uc936OuqhLObu4IjuyICW8uhn9Yu+b/AAFrdmcDAB57a4/Z/j+n9sTIvsqc+VeBA3vDpW0bnBd8N/sr0fDsHBwx6pV5kiNY7MyqUdIj3LDCXQcUc3cCRX0fj24dDI9EMDwSwfBIBMMjEQyPRDA8EsHwSATDIxEMj0QwPBLB8EgEwyMRDI9EMDwSwfBIBMMjEQyPRPD0RhLBZzwSwfBIBMMjEQyPRDA8EsHwSATDIxEMj0QwPBLxXzS/GVdCb8iEAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 200x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(A_5_by_3_col_order, '矩阵，5 x 3, 先列后行', 7, -7)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "66f1c225-98e2-4e50-8138-8badf98a94e4",
   "metadata": {},
   "source": [
    "#### 从 3 * 5 到 5 * 3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 63,
   "id": "8fba7a79-47e2-49eb-b9d4-8a5512e54e03",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5],\n",
       "       [-4, -3, -2],\n",
       "       [-1,  0,  1],\n",
       "       [ 2,  3,  4],\n",
       "       [ 5,  6,  7]])"
      ]
     },
     "execution_count": 63,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5.reshape(5,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "id": "b1e29ba3-f99a-4228-a27a-f78907338ee0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJ4AAAD7CAYAAACbvC2SAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAARSklEQVR4nO3df1TThf7H8dc2fm78FARBQUTAXxh50yw11MQySysrS+10tUyz3+bVTPpxy7pmJzNTK2+ZlT/IstQyNc3SRK8mgSaICCqigPz+JRtsbLt/dFtfUthm8nnPr6/HOZ3T59Nsr3N89tnwtH1UVqvVCiKFqaUH0JWJ4ZEIhkciGB6JYHgkguGRCIZHIhgeiWB4JILhkQg3Zx78t/7vttWONpO+/1EMeWid9Ayn7Vx+N8Yt2CU946KkzBhs9zG84pEIhkciGB6JYHgkguGRCIZHIhgeiWB4JILhkQiGRyIYHolgeCSC4ZEIhkciGB6JcOr/x2sL6fsfveD5txfvxaerDio7xkmRYb6YendvJMS1h1oN5BfW4p/v70NppUF6WoseubkbBsd3aHYut6gWL6ZkKLpDPLzht6xodjxwQGe8mDwUO344IbTIMeHtdVg8ewg2787Hio1HUK83oXO4L4wmi/Q0uw6erMT7W4/ajpssyn99jnh4FX+6OgxOjELaL4UoLKoVWuSYyWPisf/wWSxbd9h2rri8XnCR40xmC2r0JtEN4uH9X+3aeWPQwM546eUfpKe0SqUCrruqA1K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DwSIfYdyH4TpsBvwpRm58yV5Si+f4TQIse5h4YgctY/4D84EWovTzSczMeJ556HPjNLelqLRp/cAZ+oTuedP7Z0NdIef0XxPaLf62/KP46y5Ef/OGE2y41xkMbPD70+T0Htvv3IefBhmCoq4dU5AubaWulprfqu391QaTS2Y//4WAz7/mMUfLFVZI9oeFZzEyxVFZITnBY+dTIai4tx4tk5tnPGwkLBRY5pLG9+V8yes6egLu8USnf9LLJHNDy3jpEIW7kFVpMRxpws1HyyFOazrv2bGDjsRlTvTkXM4rfh178fjGdLULI6BWVrv5Ce5jC1uzui7h+No2+tkNsg9cTGnExULXgJZS88jqp3XoMmMAghby6H2te1b1TiGRmB0Anj0JB/CkcnTkZpylpEvZiM4Dtvl57msE53JMEjwBcnP14vtkHsiteQttf29004jvLsX9Fh+QZok27DufWrpWbZp1KhPjMLZxYsBADoj2TDOzYGIePHoXz9RuFxjun60F0o3vITDMWlYhtc5o9TrI0NMJ06DrfwCOkprTKVlcGQm9fsnCHvODzDw4QWOUcbGY7QpAHI+3Cd6A6XCQ9u7nCLiIK5slx6SavqfsmAV3Tze615dYlCY1GR0CLndJ00Bo2lFSj6dqfoDrHw/B96Ch7xf4MmNBwe3XohKHk+1Fod9Ds2SU1yyNmPPobP1QkInzYVnp0jETTqNoTcNxYlK1347cHvVCpETxqDE59sgFX4j67E3uNpgkMR9OxrUPsFwFJThcacTJROnwRz6VmpSQ6pP5yJ3GlPIGLmM+j4xKNoPH0Gp16dh4qvXfs/GADokDQAus4dceKjL6WnyIVXOX+O/Qe5qOofd6L6x53SM5x2dvsel/l2Atd5j0dXFIZHIhgeiWB4JILhkQiGRyIYHolgeCSC4ZEIhkciGB6JYHgkguGRCIZHIhgeiWB4JILhkQiGRyJ490YSwSseiWB4JILhkQiGRyIYHolgeCSC4ZEIhkciGB6J+C91hgY+4Ih5fQAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 200x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(A_3_by_5.reshape(5,3), '从 3 X 5 到 5 X 3', 7, -7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "2a08198d-9e87-43ea-a5b4-e2cb53ab7e92",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5],\n",
       "       [-4, -3, -2],\n",
       "       [-1,  0,  1],\n",
       "       [ 2,  3,  4],\n",
       "       [ 5,  6,  7]])"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 不指定顺序就默认先行后列，这个顺序应该是原来张量的从上到下，从左到右的顺序读取的\n",
    "np.reshape(np.reshape(a_1D_array, (3,5)), (5,3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "id": "6bd254fe-9f09-42fa-8511-821cddc7ce0e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5],\n",
       "       [-4, -3, -2],\n",
       "       [-1,  0,  1],\n",
       "       [ 2,  3,  4],\n",
       "       [ 5,  6,  7]])"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array.reshape(3,5).reshape(5,3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "id": "e529fa84-8b0d-41d6-b053-ef5563cb8b24",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5],\n",
       "       [-4, -3, -2],\n",
       "       [-1,  0,  1],\n",
       "       [ 2,  3,  4],\n",
       "       [ 5,  6,  7]])"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array.reshape(3,-1).reshape(5,-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "id": "257ec1df-16d5-4c9b-b6e7-cdef2ee8fb4d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -4, -1],\n",
       "       [ 2,  5, -6],\n",
       "       [-3,  0,  3],\n",
       "       [ 6, -5, -2],\n",
       "       [ 1,  4,  7]])"
      ]
     },
     "execution_count": 64,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5_col_order.reshape(5,3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b289814a-fa6a-4fe0-ba37-722e1d24f03d",
   "metadata": {},
   "source": [
    "### 变成三维 3D\n",
    "此时问题开始变得复杂了，3D可以是空间，但是Image的表示中也是3D的。这里我们就得考虑，所谓的传统的XYZ坐标轴在这里不能这么看了，也就是说如何看待第一个X的维度含义。\n",
    "我通过这种方法提高维度之后，有一种理解的办法是3个3*3的矩阵的张量，也就是3维的张量的含义。其中，A_3D_3_by_3_by_3 [0]是选定的第一个3*3矩阵。\n",
    "如果到这里我都没理解错的话，那么我的疑问是，我似乎不能随意的认为第一个维度的3是一个矩阵的行或者列，也就是说，似乎我只能这么解读这个三维张量\n",
    "每个矩阵内部才有明确的行列结构。因此，只能把第一个维度理解为“张量包含的二维矩阵的数量”，而不是直接将其理解为某个方向上的行列排列。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "429be622-d96e-48ee-ad9c-7b7f875991b9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-13, -12, -11, -10,  -9,  -8,  -7,  -6,  -5,  -4,  -3,  -2,  -1,\n",
       "         0,   1,   2,   3,   4,   5,   6,   7,   8,   9,  10,  11,  12,\n",
       "        13])"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array_long = np.arange(-13,13 + 1) # [-13,13] 的一个结构 \n",
    "a_1D_array_long"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "id": "4593c8fd-98ea-401f-a0d6-b909ed360676",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGg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BEHcUIQRxxxxBFHHHEQJwRxxBFHHHHEEQfw/wDFEfs9htyoigAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_1D(a_1D_array_long, '1D数组，27元素')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "ebd40204-bec5-40b9-8c51-8bc7c32e4417",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[-13, -12, -11],\n",
       "        [-10,  -9,  -8],\n",
       "        [ -7,  -6,  -5]],\n",
       "\n",
       "       [[ -4,  -3,  -2],\n",
       "        [ -1,   0,   1],\n",
       "        [  2,   3,   4]],\n",
       "\n",
       "       [[  5,   6,   7],\n",
       "        [  8,   9,  10],\n",
       "        [ 11,  12,  13]]])"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3D_3_by_3_by_3 = a_1D_array_long.reshape(3,3,3)\n",
    "A_3D_3_by_3_by_3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "bd313db9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3D_3_by_3_by_3.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "b420a5f3-2eb2-4a8b-8544-288e0db5f944",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[[-13, -12, -11],\n",
       "        [-10,  -9,  -8],\n",
       "        [ -7,  -6,  -5]],\n",
       "\n",
       "       [[ -4,  -3,  -2],\n",
       "        [ -1,   0,   1],\n",
       "        [  2,   3,   4]],\n",
       "\n",
       "       [[  5,   6,   7],\n",
       "        [  8,   9,  10],\n",
       "        [ 11,  12,  13]]])"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_1D_array_long.reshape(3,3,-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "id": "51ad0923-b431-4a4c-80df-bd2072af27f8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAK4AAACuCAYAAACvDDbuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAOC0lEQVR4nO3deXTTdbrH8U/b7GnTtOm+0r1iS6FQmGKxzIgII3BVFBn16iDKOXdQ0VmEw5xBcRu9d3SUi8wBUaZeFXEUHUBBFgvIWpQudAO60H2jTbolaZMm8wdOnDpFktLmm+ee5/UX3+SXnqfw7q/fhJP8vOx2ux2MEeMtegDGRoPDZSRxuIwkDpeRxOEykjhcRhKHy0jicBlJHC4jicNlJElcOThzxqbxmsOtzp7+FbIX5okeY8yc3P0QfrriE9FjjIn8LYudOo7PuIwkDpeRxOEykjhcRhKHy0jicBlJHC4jicNlJHG4jCQOl5HE4TKSOFxGEofLSOJwGUkcLiOJw2UkcbiMJA6XkeTSW3fG0s9mx2PxnRORmhqMAK0SSx/YgQsXO4cd8/s1uZieFYXgIDVMJguKz7Viw8aTuFRnEDP0VeRmx+COeclITdRBq1HgwSd24WKt3nG/xleGR+6bjOlTIhAarIahx4yjpxqw5b1C9BstAicf2awpEVh4czySY7Xw95XjkecOorqxe9gxC2bF4Zbp0UiK0UKtlGLBql3oN7nvexF2xlUqJSgqacX/vnnqqsdUVHZg/fNfYfHS7Vi5aje8ALy5YSG8vb3cN6gTlAoJzlW0Y1Pe2RHvDwpUIUinwsZ3vsEDj+3CC68fx08yI7D2iZluntQ5CrkEpVWXsWVn6VWPkct8UFDWivf3Vrpxsu8JO+N+vvcCACA83O+qx+z8rNzx55aWXmzaXIAd79+Li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oKlv12HR1/agJ8/8hgaL1TgrbVPwGoZFDaTkDNuTcFhnNz+pmM9Z+WzCE280bG+ePIA4rNmw0cqEzGeyyqOH8KBd153rO/87QsAgMTMbEydvxgAEBKbiOaLZSg+tAfRN2SIGNMphfn78enG/3Gsl63/EzJuvsWxDpsQj6ikVLyy7G5UFpxE2k25IsYUE270pOkImpDsWKu03++d2qrK0NPWhNyHV4sYbVQSMrMRlpDqWKs0Wnj7+EAXGTvsOF1kDJrOl7p7PJdMnJGD6JSJjrW/7t8/50ATGARtSBguNze4c7RhhIQrVaggVahGvO/iif3QxSQiMCrOzVONnkypgkw5/PsJjU9BV8vwf1h9SxM0QaHuHM1lcpUKctXI/zb/1N/Tje6OdqFP1jxqjztoMqKu8DiSZs4VPcp1y/r5PTh/6ghK8r+AvrUJhfs/Q3XhSWTMWSR6NJcMmIz4fOtG1FWUoqutBdUlZ5G3fjVUGn+kZYvZJgAe9qrCpW+Pwm63I27azaJHuW5JWTmY8/AqFOzajvx330RAeBQWrXoGUSlpokdzibe3D1rranD2q30w9/fBL0CH+EmZuG/N+muemceTR4WbnDMPyTnzRI8xZtJz5yE9l/b3I5XLsfz510SP8W88aqvAmLM4XEYSh8tI4nAZSRwuI4nDZSRxuIwkDpeRxOEykjhcRhKHy0jicBlJHC4jicNlJHG4jCQOl5HE4TKSOFxGEofLSOJwGUkcLiPJy26320UPwZir+IzLSOJwGUkcLiOJw2UkcbiMJA6XkcThMpI4XEYSh8tI+gcsJhn4vTFTawAAAABJRU5ErkJggg==",
      "text/plain": [
       "<Figure size 200x200 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(A_3D_3_by_3_by_3[0,:,:], '3D_第一页', 13, -13)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "id": "f82e1a31-4267-4e4f-b877-33588122410a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAK4AA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9y0qfDydFc9pxfNhLs0uwg7v/geb65ORdAwP9VzHDLI0x2jRpz/JiYmPBCHv6tB3kelWDI/XvEy+5SeqIe5sQO3P13cc6zbasP+o2bk7/gBh3JugbubTsk25eHabDYsXbUDRXuOIW9VKkYOD1A9yelsNhs6u6yqZ9htythAbFk6vdexxRsOIHS4AfffGKEsWkAD4S5ZWYStO8qwdtlM6H08UW0+//qnn8EL3l7a+A7WHi/l7ce1E0YiyKRHS1sXCvdU4D+HzyAna4bqaXbT+3giYmTvvwMfL3cEGAYhYqTal8WUh1uw5WsAwD2Pvt3r+DOLknFbcrSCRY4x17chfeUuVNe2wk8/CJFXDEFO1gzExQarnjagKA/3212Pq57gVMsWXKN6gkvlLdLG56e513GJ+oLhkkgMl0RiuCQSwyWRGC6JxHBJJIZLIjFcEonhkkgMl0RiuCQSwyWRGC6JxHBJJIZLIjFcEonhkkgMl0RiuCQSwyWRdDabzaZ6BJG9+IxLIjFcEonhkkgMl0RiuCQSwyWRGC6JxHBJJIZLIv0Pwp/fRcm/GfYAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 200x200 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(A_3D_3_by_3_by_3[1,:,:], '3D_第二页', 13, -13)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "id": "8656090a-ad6d-4856-a08e-67196ecb2e13",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAK4AAACuCAYAAACvDDbuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAMG0lEQVR4nO3deXDU9R3G8ee3u9kr98mRcIUrIJCgEES0gALSKigUFVHE4oFSVGrpMFVGLFKpHaGiVBQRGVQU66CCDAgYKkEhIeW+IleAH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k/88nXDS7veX4Buj1+H6L69URxxq7rPa8BPscNsJCIMPi8XrgqK1VPaRVdSAi6PfkAnOWVKN9/bW9w9Cfln57+/0RnMqLHS7NQ9PnX8FTVqJ7TIu3vGoYhny6CwWpBXdFFZIycCkdpWcB38BE3QDSDAanL/wHoNBz+08uq57RY8bYsbEy7F5tvmYiiTZm49bM3YIqPCfgOhhsAmsGAtBVvwNIpCTnjp4p9tAUAT20dqk+eRWnWfmQ9/iJ8bje6PjYh4Dv4VOE6+zlaa9dOyB77CFxl5aon+ZemQW8yBvxmAx6uzmqFqVPH+sumpCRYeqXAU14BZ1ER9JGRMLZvB2PCT3/rtHTpAgBwXSyBu6Qk0HObpA+1wtrl0v2xdEpCeJ8UuMoq4Dh/AWkr30REam/smTgNml4PY0IcAMBVVgGfy6Vq9hUZQq0I63bpvoR2SUJUagqctgo4SsvR58WnkL8uA3VFF2GKjUL36ZNgTWqLs//aFPCtzTp3mD9OwRSeno6Uj1c1Ol6y9gucnv1nxI4fh+TXFjS6vuDNJSh8a0mrbx/w7ymYYoakI339h42OF6xeixOvLcHQ/RlX/LnsMZNh+z7bLxv8dQqmhKHpGPHvxvfl1Mq1yH5qLoasXojYQakwxUXDUVoO2+6DODR/KWw5B1t92z+71lMwBTzcYMBzhwUvnjuMftEYLonEcEkkhksiMVwSieGSSAyXRGK4JBLDJZEYLonEcEkkhksiMVwSieGSSAyXRGK4JBLDJZEYLonEcEkkhksiMVwSqVnv8iUKFnzEJZEYLonEcEkkhksiMVwSieGSSAyXRGK4JBLDJZH+Cyc3de03xZOnAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 200x200 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(A_3D_3_by_3_by_3[2,:,:], '3D_第三页', 13, -13)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0e4bc83b",
   "metadata": {},
   "source": [
    "#### Image\n",
    "在深度学习中，一个形状为 (batch_size, height, width, channels) 的张量就代表了多个样本（batch_size），每个样本都有图像的高度、宽度和颜色通道。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "22d0a4e9",
   "metadata": {},
   "source": [
    "np.random.randint(low, high=None, size=None, dtype=int)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "2b92abaa",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 示例：创建2个8x8的RGB彩色图像\n",
    "color_image = np.random.randint(1, 256, (8, 8, 3), dtype=np.uint8)\n",
    "# 示例：创建2个8x8的灰度图像\n",
    "gray_image = np.random.randint(1, 256, (8, 8), dtype=np.uint8)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "cca640f9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "color_image.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "e1d28606",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "gray_image.ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4363195c",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 示例：创建一个8x8的RGB彩色图像\n",
    "color_image = np.random.randint(0, 256, (8, 8, 3), dtype=np.uint8)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ea127764",
   "metadata": {},
   "source": [
    "### 最后一跃 四维张量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "469e3b9e",
   "metadata": {},
   "outputs": [],
   "source": [
    "a_1D_array_for_4_dim = np.arange(-13,13 + 1) # [-13,13] 的一个结构 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "8497fdfc",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Focus : Reshape的结果必须正好是原来所有的元素，一个都不能落下\n",
    "A_4D_2_by_3_by_2_by_3 = a_1D_array_for_4_dim.reshape(1, 3, 3, 3)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6f7842da",
   "metadata": {},
   "source": [
    "最终结构可以解读为包含 1 个 (3, 3, 3) 的三维张量。最左边的维度（第一个维度）：可以理解为包含了几个“子结构”\n",
    "当维度逐渐增高时，这种解读方式确实就是依次从左到右解释成“几个集合”，“每个集合中的行数、列数、深度”等，而左边的维度越靠前，代表的层次越高。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e6a5e913-d896-41ff-b285-41b414980fb6",
   "metadata": {},
   "source": [
    "### 视图 vs 副本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "af0d60ef-bee4-4ca5-bd96-acf44f6dac2f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 判断是否共享内存？\n",
    "np.shares_memory(a_1D_array, A_5_by_3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "id": "e07fab61-db80-4fcf-8574-686301f29aa3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.shares_memory(a_1D_array, a_col_vector)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "c52a7f8f-6263-4bf6-8c38-46eacc6c04e6",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.shares_memory(a_1D_array, a_row_vector)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "3791d35d-66fe-4204-999d-2ed1b74f517f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1 2 3 4]\n",
      "[[0 2]\n",
      " [3 4]]\n"
     ]
    }
   ],
   "source": [
    "# 新形状和原始形状的元素数量相同，返回视图\n",
    "a = np.array([[1, 2], [3, 4]])\n",
    "b = a.reshape(4)\n",
    "print(b)     # [1 2 3 4]\n",
    "b[0] = 0\n",
    "print(a)     # [[0 2], [3 4]]"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "dcac14ab-442d-40c5-bb7d-5b0c113477fc",
   "metadata": {},
   "source": [
    "### 转置"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "id": "9ba216cf-276f-4413-be37-6219a2d4519d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7])"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 一维数组的转置还是其本身\n",
    "a_1D_array.T\n",
    "# 请大家学习使用numpy.swapaxes()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "4c69d085-cbee-4555-ab19-15077af156c1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7],\n",
       "       [-6],\n",
       "       [-5],\n",
       "       [-4],\n",
       "       [-3],\n",
       "       [-2],\n",
       "       [-1],\n",
       "       [ 0],\n",
       "       [ 1],\n",
       "       [ 2],\n",
       "       [ 3],\n",
       "       [ 4],\n",
       "       [ 5],\n",
       "       [ 6],\n",
       "       [ 7]])"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_row_vector.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "c974cbdd-db34-4f80-9424-833c2bd48c7c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7],\n",
       "       [-6],\n",
       "       [-5],\n",
       "       [-4],\n",
       "       [-3],\n",
       "       [-2],\n",
       "       [-1],\n",
       "       [ 0],\n",
       "       [ 1],\n",
       "       [ 2],\n",
       "       [ 3],\n",
       "       [ 4],\n",
       "       [ 5],\n",
       "       [ 6],\n",
       "       [ 7]])"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.transpose(a_row_vector)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "id": "cc88af47-cb73-47d8-bb93-7d03a8ba920d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a_col_vector.T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "10f9d123-62e5-4823-86d5-67ea8be0f4a5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.transpose(a_col_vector)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "id": "974ac732-3f16-414c-ae80-8728ea463167",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -2,  3],\n",
       "       [-6, -1,  4],\n",
       "       [-5,  0,  5],\n",
       "       [-4,  1,  6],\n",
       "       [-3,  2,  7]])"
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5_T = A_3_by_5.T\n",
    "A_3_by_5_T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "id": "fa2b9e19-8267-4eaa-9e33-c13b14bc74cf",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJ4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3CtmVJpvW4xAUIi+mK8Ng4TH33E9RVVyJt1zZ8k/Q6Jr39IVw8vKw5nsXmrUzF2UsV+PK1m+vctYjJD6Fgxz7UFxSLzWDV8KJ79kGbqE6mtZv3L6+JHJyc4R0UAu+gEIREd8bSp8Yjbfd2xI8cb83xLDJvZSp+TM3Hqlf7I9BHLT1Oi6nDghEwsDeSRz4jOodVw3N0VsPRufn/SEYYoddqrDCR5YxGI+Z9noYfUvLweWI/hPi7So9kkYiJI9FYXIb8bXtE5xB9jadpqMf+b1YhumdvuHr6oL6mCinfbUJVWQk63dVPcrRrmvtZKrb+JxdLX+gDFyc7lFTUAwDc1PZwclDES+ZrU6nQfuJInF+5CUa9XnQU0b8pGxsblObl4uc936OuqhLObu4IjuyICW8uhn9Yu+b/AAFrdmcDAB57a4/Z/j+n9sTIvsqc+VeBA3vDpW0bnBd8N/sr0fDsHBwx6pV5kiNY7MyqUdIj3LDCXQcUc3cCRX0fj24dDI9EMDwSwfBIBMMjEQyPRDA8EsHwSATDIxEMj0QwPBLB8EgEwyMRDI9EMDwSwfBIBMMjEQyPRPD0RhLBZzwSwfBIBMMjEQyPRDA8EsHwSATDIxEMj0QwPBLxXzS/GVdCb8iEAAAAAElFTkSuQmCC",
      "text/plain": [
       "<Figure size 200x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(A_3_by_5_T, '矩阵，3 x 5, 转置', 7, -7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "id": "4c3e0d3b-d2dd-48d1-abe3-0926d566eba1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -2,  3],\n",
       "       [-6, -1,  4],\n",
       "       [-5,  0,  5],\n",
       "       [-4,  1,  6],\n",
       "       [-3,  2,  7]])"
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.transpose(A_3_by_5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "id": "419af092-4f6a-418b-943e-1e5b98e8ce32",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原始数组：\n",
      "[[  1   2 200]\n",
      " [100   5   6]]\n",
      "使用.transpose()方法得到的数组的转置：\n",
      "[[  1 100]\n",
      " [  2   5]\n",
      " [200   6]]\n",
      "使用.T属性得到的数组的转置：\n",
      "[[  1 100]\n",
      " [  2   5]\n",
      " [200   6]]\n"
     ]
    }
   ],
   "source": [
    "# 视图 vs 副本\n",
    "# 定义一个二维数组\n",
    "arr = np.array([[1, 2, 3], [4, 5, 6]])\n",
    "\n",
    "# 使用.transpose()方法得到数组的转置\n",
    "arr_transpose = arr.transpose()\n",
    "\n",
    "# 使用.T属性得到数组的转置\n",
    "arr_T = arr.T\n",
    "\n",
    "# 修改新数组中的元素\n",
    "arr_transpose[0, 1] = 100\n",
    "arr_T[2, 0] = 200\n",
    "\n",
    "# 输出结果\n",
    "print(\"原始数组：\")\n",
    "print(arr)\n",
    "print(\"使用.transpose()方法得到的数组的转置：\")\n",
    "print(arr_transpose)\n",
    "print(\"使用.T属性得到的数组的转置：\")\n",
    "print(arr_T)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d467a732-1c65-4c03-8f37-313e035e0458",
   "metadata": {},
   "source": [
    "### 扁平化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "id": "664acacf-18e2-45eb-844d-2049b57d09cb",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7])"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5.ravel()\n",
    "# 需要注意的是，ravel()函数返回的是原始数组的视图（view），而不是其副本（copy）。\n",
    "# 因此，如果修改新数组中的任何元素，原始数组也会受到影响。\n",
    "# 如果需要返回一个数组副本，可以使用flatten()函数。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "d8d54076-1bb3-4d9d-8256-9c13e69fa70a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(15,)"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5.ravel().shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "63a887f7-aea1-48de-bee5-40c7163c806f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1"
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5.ravel().ndim"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "id": "c886001a-1ac7-4704-8be0-d752e2c01992",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7])"
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5.reshape(-1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "id": "5aaa1e0e-63de-4370-904c-50447abe4926",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([-7, -2,  3, -6, -1,  4, -5,  0,  5, -4,  1,  6, -3,  2,  7])"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5.ravel(order = 'F')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "id": "c7d7b932-9e09-4551-a253-e881090286db",
   "metadata": {},
   "outputs": [],
   "source": [
    "A_3_by_5_flatten = A_3_by_5.flatten()\n",
    "# A_3_by_5_flatten是A_3_by_5的副本"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "id": "89c6723b-8f68-49ba-adb0-462e249fc737",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1000,   -6,   -5,   -4,   -3,   -2,   -1,    0,    1,    2,    3,\n",
       "          4,    5,    6,    7])"
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5_flatten[0] = 1000\n",
    "A_3_by_5_flatten"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "id": "d50256e3-5cda-4150-8d2f-2c0554b3dd30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3],\n",
       "       [-2, -1,  0,  1,  2],\n",
       "       [ 3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5\n",
    "# A_3_by_5并没有变化"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "f94a16e3-a033-4751-af78-5d068a46d7dd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原始数组：\n",
      "[[200   2   3]\n",
      " [  4   5   6]]\n",
      "使用flatten()函数得到的一维数组：\n",
      "[   1    2    3    4    5 1000]\n",
      "使用ravel()函数得到的一维数组：\n",
      "[200   2   3   4   5   6]\n"
     ]
    }
   ],
   "source": [
    "# 视图 vs 副本\n",
    "\n",
    "# 定义一个多维数组\n",
    "arr = np.array([[1, 2, 3], [4, 5, 6]])\n",
    "\n",
    "# 使用flatten()函数将多维数组降为一维数组\n",
    "new_arr1 = arr.flatten()\n",
    "\n",
    "# 使用ravel()函数将多维数组降为一维数组\n",
    "new_arr2 = arr.ravel()\n",
    "\n",
    "# 修改新数组中的元素\n",
    "new_arr1[-1] = 1000\n",
    "new_arr2[0] = 200\n",
    "\n",
    "# 输出结果\n",
    "print(\"原始数组：\")\n",
    "print(arr)\n",
    "print(\"使用flatten()函数得到的一维数组：\")\n",
    "print(new_arr1)\n",
    "print(\"使用ravel()函数得到的一维数组：\")\n",
    "print(new_arr2)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "221b67bc-102c-4899-b921-a8a34d91b306",
   "metadata": {},
   "source": [
    "### 旋转"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "id": "0188bdac-cdad-4594-ac29-43f88d163623",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-7, -6, -5, -4, -3],\n",
       "       [-2, -1,  0,  1,  2],\n",
       "       [ 3,  4,  5,  6,  7]])"
      ]
     },
     "execution_count": 136,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "A_3_by_5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "de1fae7f-409b-4121-a0b9-4ad459b60701",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-3,  2,  7],\n",
       "       [-4,  1,  6],\n",
       "       [-5,  0,  5],\n",
       "       [-6, -1,  4],\n",
       "       [-7, -2,  3]])"
      ]
     },
     "execution_count": 123,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.rot90(A_3_by_5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "id": "8f48a2aa-9725-4359-8c5b-1f4ff23eea91",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJ4AAAD7CAYAAACbvC2SAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAARFUlEQVR4nO3de3zO9f/H8ee1866dD3ayzdgBMzSRYomi5Bf5qhy7lVNE5/oW360o6qv8WvJF5VuSIpSQY5HC8HWYjYyxGTZ2vDY7n67j749uXb4XZrv02/X6lOf9dnO79fm4yvOmx23XdbnZ9VaZTCYTiGzMTnoA3ZoYHolgeCSC4ZEIhkciGB6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kpLXJZU4K0/XsBAK9PHGvxc4kLP0Hn+J4Ss26orEaHmRtyoKnRwcPZHjGBavx7XCf0ifQS2aOI8NZvPIX1G09Jz2ixNsEh+GpvqvQMq7z9cAfpCRYU8VRLtx6GRyIYHolgeCSC4ZEIhkciGB6JYHgkguGRCIZHIhgeiWB4JILhkQiGRyIYHolgeCSC4ZEIhkcieHojieBXPBLB8EgEwyMRDI9EMDwSwfBIBMMjEQyPRDA8EvF/5VkZVxmhJOkAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 200x300 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(np.rot90(A_3_by_5), '逆时针旋转90度', 7, -7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "id": "a7c4ca6b-8a82-428a-b41d-0e4cc7c9f622",
   "metadata": {},
   "outputs": [],
   "source": [
    "A_3_by_5_anti_c_90 = np.rot90(A_3_by_5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "id": "3a3d81e1-7f32-4ed9-8300-71505a1f9e1d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原数组：\n",
      "[[  1 100]\n",
      " [  3   4]]\n",
      "修改后的视图：\n",
      "[[100   4]\n",
      " [  1   3]]\n"
     ]
    }
   ],
   "source": [
    "# 视图 vs 副本\n",
    "\n",
    "# 创建一个 2x2 的二维数组\n",
    "arr = np.array([[1, 2], [3, 4]])\n",
    "\n",
    "# 将数组逆时针旋转90度，得到数组的视图\n",
    "rotated_arr = np.rot90(arr)\n",
    "\n",
    "# 修改视图的值\n",
    "rotated_arr[0, 0] = 100\n",
    "\n",
    "# 打印原数组和修改后的视图\n",
    "print(\"原数组：\")\n",
    "print(arr)\n",
    "\n",
    "print(\"修改后的视图：\")\n",
    "print(rotated_arr)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "96628e7b-7ab6-4733-a3cb-0e4e4c60f200",
   "metadata": {},
   "source": [
    "### 翻转"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "id": "42c5f793-2736-4211-9ddd-b90d61aa1159",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 7,  6,  5,  4,  3],\n",
       "       [ 2,  1,  0, -1, -2],\n",
       "       [-3, -4, -5, -6, -7]])"
      ]
     },
     "execution_count": 137,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.flip(A_3_by_5)\n",
    "# 沿着所有轴翻转"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "id": "214cd0a7-58a9-4f90-ae7d-be4024b8e9f2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAPwAAACfCAYAAADdy7STAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8qNh9FAAAACXBIWXMAAA9hAAAPYQGoP6dpAAAQQ0lEQVR4nO3deVTU9eLG8WcY1mFfZBMQFVARNUvLlFATs7xXb9cWt065pdlu/lKD0sq8Wjcrr7ZQYVaaVqZWiqVpmuh1QdEEERBFlHXYl2GZ7f7RaWxaYIZfzWf087zO8Zw+X6d8LN/MDMSMwmg0GkFEUnAQPYCIbIfBE0mEwRNJhMETSYTBE0mEwRNJhMETSYTBE0mEwRNJhMETScTRmht/ouj1V+34S00x5uJIz96iZ1jtpoKzuDx2kOgZnRKWlgHNgttFz7Ca6pVvoP/kftEzOkU55aMOb8N7eCKJMHgiiTB4IokweCKJMHgiiTB4IokweCKJMHgiiTB4IokweCKJMHgiiTB4IokweCKJMHgiiTB4IolY9f3wf6bxF/bAIzLsN9fz3tyAjEdfFLDIck5BgYhY8H/wHp4AB1cXtFwoxPlnnoUmK1v0tHZ5TZ0Nr6mzza7pqytRet/V9X3rjiMnwvmO6dAe2Art1ymi57Rr07FybMooR3FtKwA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sPFCIr+1PTuUJ95fMMA68LQfdIXyx6dpeIabYN3sVNBRc3VYe3M8IIvfa3fzBFcnJ1g5PrlSC6D7kNIbGDzG5z4L2l6HbDcEQOvtXW8/5Qi1aPltr270k8XB3h7+mK2ib7+Xfe3KJDcYvO7NrZwhqEB3uaXQsP8kB5lcaW0zqk0Wih+YNPiP5jXB+cyalAfn6VjVf9ROhz+LaWZqR/sR4xg4fCw8cfzY31yPhmG+qr1Ohz8wiR0zrk4u4JF3fzP3wOSiVcPX3gGdhV0KqOuTg54O6hkTiaV4maplZ08XLFpFu6o6FZi2P59vOw+Pds+iYXSx4aglN5lTh5tgI3xgVj6IAQPPnK1fHa/e7uThg9qideW3VI2AahwTs4OKCyuAg/7vsWmvo6uHl6ITSqN6a9tBqBEd1FTrtmGYxAeIA7bokNgruLI2qa2nCmqBartuegRWv755TWSM8swWsfn8DUsb3w+OTrcKmsAYvf+i9OnxNzb2mtMaOjAQXw7a58YRuEBu/o7IJ7FywVOeFPZS/P29uj1Rmw4ovTHd/QTu1ML8TO9ELRMzply7Yz2LLtjNAN/H/piSTC4IkkwuCJJMLgiSTC4IkkwuCJJMLgiSTC4IkkwuCJJMLgiSTC4IkkwuCJJMLgiSTC4IkkwuCJJMLgiSTC4IkkwuCJJKIwGo32+c4DRPSn4z08kUQYPJFEGDyRRBg8kUQYPJFEGDyRRBg8kUQYPJFEGDyRRP4HYuj2UoL9gDMAAAAASUVORK5CYII=",
      "text/plain": [
       "<Figure size 300x200 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "visualize_2D(np.flip(A_3_by_5), '沿着所有轴翻转', 7, -7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "21d5ae3a-16bd-4f18-b12b-960f35934ad7",
   "metadata": {},
   "outputs": [],
   "source": [
    "# 沿着指定的轴翻转\n",
    "\n",
    "# 沿着指定轴进行翻转\n",
    "arr3 = np.array([[1, 2], [3, 4], [5, 6]])\n",
    "flipped_arr3 = np.flip(arr3, axis=0)  # 沿着第一个轴进行翻转\n",
    "print(flipped_arr3)\n",
    "# 输出 [[5 6] [3 4] [1 2]]\n",
    "\n",
    "flipped_arr4 = np.flip(arr3, axis=1)  # 沿着第二个轴进行翻转\n",
    "print(flipped_arr4)\n",
    "# 输出 [[2 1] [4 3] [6 5]]\n",
    "\n",
    "flipped_arr5 = np.flip(arr3, axis=(0, 1))  # 沿着所有轴进行翻转\n",
    "print(flipped_arr5)\n",
    "# 输出 [[6 5] [4 3] [2 1]]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 139,
   "id": "1295c28e-d630-40ff-81bd-a51ec2481cd8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 3,  4,  5,  6,  7],\n",
       "       [-2, -1,  0,  1,  2],\n",
       "       [-7, -6, -5, -4, -3]])"
      ]
     },
     "execution_count": 139,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.flipud(A_3_by_5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "id": "7d311dfb-39d1-4482-bd0c-51a60758438e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[-3, -4, -5, -6, -7],\n",
       "       [ 2,  1,  0, -1, -2],\n",
       "       [ 7,  6,  5,  4,  3]])"
      ]
     },
     "execution_count": 140,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.fliplr(A_3_by_5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2a76d332-aee9-4e69-b1d7-20b5eac340a5",
   "metadata": {},
   "outputs": [],
   "source": [
    "# Repo: https://github.com/Visualize-ML\n",
    "# Book 1 Python for Beginners  |  From Basic Arithmetic to Machine Learning\n",
    "# Published and copyrighted by Tsinghua University Press\n",
    "# Beijing, China, 2023"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.18"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
